DynamicCell.cs 813 B

12345678910111213141516171819202122232425262728293031
  1. using ClosedXML.Excel;
  2. namespace ExcelORM.Models
  3. {
  4. public record DynamicCell
  5. {
  6. public int Position { get; set; }
  7. public string? Header { get; set; }
  8. public Type? Type { get; set; }
  9. public object? Value { get; set; }
  10. public static List<DynamicCell>? MapHeader(IXLCells? headerCells)
  11. {
  12. if (headerCells == null || !headerCells.Any()) return null;
  13. var map = new List<DynamicCell>();
  14. foreach(var cell in headerCells)
  15. {
  16. var headerItem = new DynamicCell
  17. {
  18. Position = cell.Address.ColumnNumber,
  19. Header = cell.Value.GetText()
  20. };
  21. map.Add(headerItem);
  22. }
  23. return map;
  24. }
  25. }
  26. }