Kit.Core/LibCommon/Kit.Helpers.OpenXml/OpenXml/Excel/ExcelData.cs

102 lines
2.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DocumentFormat.OpenXml.Spreadsheet;
namespace Kit.Helpers
{
public class ExcelStatus
{
public string Message { get; set; }
public bool Success
{
get { return string.IsNullOrWhiteSpace(Message); }
}
}
public class ExcelComment
{
public string Reference { get; set; }
public string Comment { get; set; }
}
public class ExcelStyle
{
public string Color { get; set; }
}
public class ExcelCell : Object
{
public bool IsHeader { get; set; }
public string Header { get; set; }
public string Value { get; set; }
public PatternFill PatternFill { get; set; }
public ExcelComment Comment { get; set; }
public override string ToString()
{
return this.Value;
}
}
public class ExcelRow
{
public ExcelRow()
{
Cells = new List<ExcelCell>();
}
public List<ExcelCell> Cells { get; set; }
public ExcelCell this[int index]
{
get
{
return Cells[index];
}
set
{
Cells[index] = value;
}
}
public ExcelCell this[string header]
{
get
{
var cell = GetByHeader(header);
Check.IsNotNull(cell, "Не найден столбец с именем: {0}".ApplyFormat(header));
return cell;
}
set
{
var cell = GetByHeader(header);
Check.IsNotNull(cell, "Не найден столбец с именем: {0}".ApplyFormat(header));
cell = value;
}
}
public ExcelCell GetByHeader(string header)
{
return Cells.FirstOrDefault(x => x.Header.ToLowerEquals(header));
}
}
public class ExcelData
{
public ExcelStatus Status { get; set; }
public Columns ColumnConfigurations { get; set; }
public List<string> Headers { get; set; }
public List<List<string>> DataRows { get; set; }
public List<ExcelRow> DataRowCells { get; set; }
public List<List<PatternFill>> PatternFillRows { get; set; }
public List<ExcelComment> Comments { get; set; }
public string SheetName { get; set; }
public ExcelData()
{
Status = new ExcelStatus();
Headers = new List<string>();
DataRows = new List<List<string>>();
DataRowCells = new List<ExcelRow>();
PatternFillRows = new List<List<PatternFill>>();
}
}
}