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(); } public List 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 Headers { get; set; } public List> DataRows { get; set; } public List DataRowCells { get; set; } public List> PatternFillRows { get; set; } public List Comments { get; set; } public string SheetName { get; set; } public ExcelData() { Status = new ExcelStatus(); Headers = new List(); DataRows = new List>(); DataRowCells = new List(); PatternFillRows = new List>(); } } }