コード例 #1
0
 public SheetTableHelper(ExcelWorksheet worksheet, TgOptions <T> gridOptions, int rowsCount)
 {
     _worksheet         = worksheet;
     _gridOptions       = gridOptions;
     _rowsCount         = rowsCount;
     _sheetColumnHelper =
         new SheetColumnHelper(worksheet, gridOptions.TableTopPosition, gridOptions.DefaultColumnOptions);
 }
コード例 #2
0
 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());
     }
 }
コード例 #3
0
        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());
        }
コード例 #4
0
        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;
        }
コード例 #5
0
 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));
     }
 }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
 protected GroupedTableLoader(TgOptions <T> gridOptions, ExcelWorksheet worksheet)
     : base(gridOptions, worksheet)
 {
 }
コード例 #8
0
 protected TableLoader(TgOptions <T> gridOptions, ExcelWorksheet worksheet)
 {
     GridOptions = gridOptions;
     Worksheet   = worksheet;
 }
コード例 #9
0
 public SimpleTableLoader(TgOptions <T> gridOptions, ExcelWorksheet worksheet)
     : base(gridOptions, worksheet)
 {
 }
コード例 #10
0
 public GroupedTableByRowLoader(TgOptions <T> gridOptions, ExcelWorksheet worksheet)
     : base(gridOptions, worksheet)
 {
 }
コード例 #11
0
 /// <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)));
 }
コード例 #12
0
 /// <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)));
 }