Skip to content

AddTable

Adds an empty table to the end of the collection. Add rows with TableRowCollection.Add.

1
myBlockCollection.AddTable(options?: object):Table

Parameters

object options optional
    Table properties to set.

Returns

The new table.

Examples

Create a table with a row for each order line

1
2
3
4
5
6
7
8
9
var writer = new Writer();
var table = writer.Sections.Add().Blocks.AddTable();

$Xml.SelectAll('Lines/Line', function (line) {
    var row = table.Rows.Add();

    row.Cells.Add().Blocks.AddParagraph().Inlines.AddRun({ Text : line.Evaluate('Product') });
    row.Cells.Add().Blocks.AddParagraph().Inlines.AddRun({ Text : line.Evaluate('Quantity') });
});

See Also