public SheetTableHelper(ExcelWorksheet worksheet, TgOptions <T> gridOptions, int rowsCount) { _worksheet = worksheet; _gridOptions = gridOptions; _rowsCount = rowsCount; _sheetColumnHelper = new SheetColumnHelper(worksheet, gridOptions.TableTopPosition, gridOptions.DefaultColumnOptions); }
public static byte[] GenerateTableGrid <T>(TgOptions <T> gridOptions, string worksheetName = null) where T : class { using (var package = new ExcelPackage()) { var worksheet = package.Workbook.Worksheets.Add(worksheetName ?? typeof(T).Name); worksheet.GenerateTableGrid(gridOptions); return(package.GetAsByteArray()); } }
private static ExcelRange GenerateTableGrid <T>(ExcelWorksheet worksheet, TgOptions <T> gridOptions, ExcelCellAddress topLeftCellAddress) where T : class { SetTableLocation(gridOptions, topLeftCellAddress); var loaderFactory = new TableLoaderFactory(); var tableLoader = loaderFactory.Create(gridOptions, worksheet); return(tableLoader.Load()); }
private static void SetTableLocation <T>(TgOptions <T> gridOptions, ExcelCellAddress topLeftCellAddress) where T : class { if (topLeftCellAddress == null) { topLeftCellAddress = new ExcelCellAddress(1, 1); } gridOptions.TableTopPosition = topLeftCellAddress.Row; gridOptions.TableLeftPosition = topLeftCellAddress.Column; }
public TableLoader <T> Create <T>(TgOptions <T> gridOptions, ExcelWorksheet worksheet) { if (gridOptions.GroupOptions == null) { return(new SimpleTableLoader <T>(gridOptions, worksheet)); } else { var loaderFactory = new GroupedTableLoaderFactory(); return(loaderFactory.Create(gridOptions, worksheet)); } }
public GroupedTableLoader <T> Create <T>(TgOptions <T> gridOptions, ExcelWorksheet worksheet) { GroupingType groupingType = gridOptions.GroupOptions.GroupingType; switch (groupingType) { case GroupingType.GroupHeaderOnColumn: return(new GroupedTableByColumnLoader <T>(gridOptions, worksheet)); case GroupingType.GroupHeaderOnRow: return(new GroupedTableByRowLoader <T>(gridOptions, worksheet)); default: throw new ArgumentException(nameof(groupingType)); } }
protected GroupedTableLoader(TgOptions <T> gridOptions, ExcelWorksheet worksheet) : base(gridOptions, worksheet) { }
protected TableLoader(TgOptions <T> gridOptions, ExcelWorksheet worksheet) { GridOptions = gridOptions; Worksheet = worksheet; }
public SimpleTableLoader(TgOptions <T> gridOptions, ExcelWorksheet worksheet) : base(gridOptions, worksheet) { }
public GroupedTableByRowLoader(TgOptions <T> gridOptions, ExcelWorksheet worksheet) : base(gridOptions, worksheet) { }
/// <summary> /// Generate table by a given grid options /// </summary> /// <typeparam name="T">Type of business objects to show</typeparam> /// <param name="worksheet">worksheet</param> /// <param name="gridOptions">table grid options</param> /// <param name="cellAddress">table top-left position</param> /// <returns>ExcelRange of a generated table</returns> public static ExcelRange GenerateTableGrid <T>(this ExcelWorksheet worksheet, TgOptions <T> gridOptions, string cellAddress) where T : class { return(GenerateTableGrid(worksheet, gridOptions, new ExcelCellAddress(cellAddress))); }
/// <summary> /// Generate table by a given grid options /// </summary> /// <typeparam name="T">Type of business objects to show</typeparam> /// <param name="worksheet">worksheet</param> /// <param name="gridOptions">table grid options</param> /// <param name="row">start table row (table top position)</param> /// <param name="column">start table column (table left position)</param> /// <returns>ExcelRange of a generated table</returns> public static ExcelRange GenerateTableGrid <T>(this ExcelWorksheet worksheet, TgOptions <T> gridOptions, int row = 1, int column = 1) where T : class { return(GenerateTableGrid(worksheet, gridOptions, new ExcelCellAddress(row, column))); }