Exemple #1
0
        public void CloneTable()
        {
            // with 100 columns and 5000 rows should execute in less than 29 sec
            // with 100 columns and 1000 rows should execute in less than 6.5 sec
            TextDocument docuemnt = new TextDocument();

            docuemnt.New();
            Table table = new Table(docuemnt, "table name", "table style");

            int numberOfColumns = 100;
            int numberOfRows    = 1000;

            // prepare data
            // add columns
            for (int i = 0; i < numberOfColumns; i++)
            {
                table.ColumnCollection.Add(new Column(table, "style name " + i));
            }

            Row row = null;

            // Add rows
            for (int i = 0; i < 2; i++)
            {
                row = new Row(table);
                for (int i1 = 0; i1 < numberOfColumns; i1++)
                {
                    Paragraph par = ParagraphBuilder.CreateStandardTextParagraph(docuemnt);
                    par.TextContent.AddRange(TextBuilder.BuildTextCollection(docuemnt, (i * numberOfColumns).ToString() + i1));
                    row.Cells.Add(new Cell(table.Document, "cell style " + i));
                    //row.Cells.Add(new Cell(table.Document));
                    row.Cells[i1].Content.Add(par);
                }
                table.Rows.Insert(0, row);
            }


            // clone many rows
            row = table.Rows[0];
            using (IPerformanceCounter counter = new PerformanceCounter())
            {
                for (int i = 0; i < numberOfRows; i++)
                {
                    Row newRow = new Row(table, row.StyleName);
                    foreach (Cell rowCell in row.Cells)
                    {
                        Cell cell = new ContentMocker().CloneAny(rowCell) as Cell;

                        newRow.Cells.Add(cell);
                    }
                }

                Console.WriteLine(string.Format(
                                      "Test executed in {0} seconds", counter.GetSeconds()));
            }
        }
        public void HeadingFilledWithTextBuilder()
        {
            string headingText = "Some    Heading with\n styles\t and more";
            //Create a new text document
            TextDocument document = new TextDocument();

            document.New();
            //Create a new Heading
            Header header = new Header(document, Headings.Heading);
            //Create a TextCollection from headingText using the TextBuilder
            ITextCollection textCol = TextBuilder.BuildTextCollection(document, headingText);

            //Add text collection
            header.TextContent = textCol;
            //Add header
            document.Content.Add(header);
            document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "HeadingWithControlCharacter.odt");
        }
Exemple #3
0
        void Supl(int id) //бланк в разрезе по поставщикам, поэтому функция для фильтрации объектов того или иного поставщика
        {
            SpreadsheetDocument spreadsheetDocument = new SpreadsheetDocument();

            spreadsheetDocument.New();
            Table table = new Table(spreadsheetDocument, "First", "tablefirst");

            for (int j = 0; j < countsup; j++)
            {
                Paragraph parag = ParagraphBuilder.CreateSpreadsheetParagraph(spreadsheetDocument);
                var       text  = TextBuilder.BuildTextCollection(spreadsheetDocument, " ");
                Cell      cell  = table.CreateCell();
                parag.TextContent.Add(new SimpleText(spreadsheetDocument, "элемент бд, где поставщик ид=ид"));//И за это тоже выебу и в прямом, и в переносном смысле за такие фразы
                cell.Content.Add(parag);
                table.InsertCellAt(0, 0, cell);
                spreadsheetDocument.TableCollection.Add(table);
                spreadsheetDocument.SaveTo("Matr.ods");
            }
        }