public override void Execute()
        {
            var columnsCount = 10;
            var workBook     = new SpreadsheetWorkbook();

            var worksheet = new SpreadsheetWorksheet("Test22");
            var table     = new SpreadsheetTable("GridTable");

            for (var i = 0; i < 10; i++)
            {
                table.Columns.Add(new SpreadsheetTableColumn()
                {
                    Name = $"Column{i}"
                });
            }

            var rowCounter = 0;
            var enumerator = Enumerable.Range(0, RowsToStream)
                             // normally you would have some other IEnumerable that you would transform into spreadsheetrows
                             // the key to use the least amount of memory as possible it to just pass it along without calling .ToList on the transformed data
                             .Select(x =>
            {
                return(createTestRow(false, columnsCount, x));
            })
                             .GetEnumerator();

            table.ActivateStreamingMode(enumerator);

            worksheet.AddTable(table);
            workBook.AddWorksheet(worksheet);
            workBook.Save(OutputFile);
        }
Example #2
0
        public override void Execute()
        {
            var columnsCount = 10;
            var workBook     = new SpreadsheetWorkbook();

            var worksheet = new SpreadsheetWorksheet("Test22");
            var table     = new SpreadsheetTable("GridTable");

            for (var i = 0; i < 10; i++)
            {
                table.Columns.Add(new SpreadsheetTableColumn()
                {
                    Name = $"Column{i}"
                });
            }

            table.ActivateStreamingMode();
            var rowCounter = 0;

            table.TableRowRequested += (s, args) =>
            {
                var spreadsheetRow = createTestRow(true, columnsCount, rowCounter);
                args.Row = spreadsheetRow;
                rowCounter++;
                args.Finished = rowCounter == RowsToStream;
            };

            worksheet.AddTable(table);
            workBook.AddWorksheet(worksheet);
            workBook.Save(OutputFile);
        }
Example #3
0
        public override void Execute()
        {
            var workBook = new SpreadsheetWorkbook();
            var sheet    = new SpreadsheetWorksheet("Sheet1");

            workBook.AddWorksheet(sheet);

            var table = new SpreadsheetTable("Table1");

            table.Columns = new List <SpreadsheetTableColumn>()
            {
                new SpreadsheetTableColumn()
                {
                    Name = "Column A"
                },
                new SpreadsheetTableColumn()
                {
                    Name = "Column B"
                }
            };

            table.Rows = new List <SpreadsheetRow>()
            {
                new SpreadsheetRow()
                {
                    RowCells = new List <SpreadsheetCell>()
                    {
                        new SpreadsheetCell()
                        {
                            Value = "Test"
                        },
                        new SpreadsheetHyperlinkCell(new SpreadsheetHyperLink("https://www.google.com", "Google me!"))
                    }
                },
                new SpreadsheetRow()
                {
                    RowCells = new List <SpreadsheetCell>()
                    {
                        new SpreadsheetCell()
                        {
                            Value = "Test2 "
                        },
                        new SpreadsheetHyperlinkCell(new SpreadsheetHyperLink("https://www.google.com", "Google me!"))
                    }
                }
            };

            sheet.AddTable(table);


            workBook.Save(OutputFile);
        }
Example #4
0
        private static SpreadsheetWorkbook setupLargeWorkbook(Action <SpreadsheetRow> afterRowCreated, int rowsToStream = 800000, bool useHyperLinks = false, bool useEnumerator = false)
        {
            var columnsCount = 10;
            var newExcel     = new SpreadsheetWorkbook();

            var worksheet = new SpreadsheetWorksheet("Test22");
            var table     = new SpreadsheetTable("GridTable");

            for (var i = 0; i < 10; i++)
            {
                table.Columns.Add(new SpreadsheetTableColumn()
                {
                    Name = $"Column{i}"
                });
            }

            if (!useEnumerator)
            {
                table.ActivateStreamingMode();
                var rowCounter = 0;
                table.TableRowRequested += (s, args) =>
                {
                    var spreadsheetRow = createTestRow(useHyperLinks, columnsCount, rowCounter);
                    args.Row = spreadsheetRow;
                    rowCounter++;
                    afterRowCreated?.Invoke(args.Row);
                    args.Finished = rowCounter == rowsToStream;
                };
            }
            else
            {
                var enumerator = Enumerable.Range(0, rowsToStream).Select(x =>
                {
                    var row = createTestRow(useHyperLinks, columnsCount, x);
                    afterRowCreated?.Invoke(row);
                    return(row);
                })
                                 .GetEnumerator();

                table.ActivateStreamingMode(enumerator);
            }

            worksheet.AddTable(table);

            newExcel.AddWorksheet(worksheet);
            return(newExcel);
        }