VegaRise.NET
HomeAPI Reference
Back to DOM

TableClass

Definition

Namespace
DOM.Elements.TableElements
Assembly
DOM.dll

Represents a table element within the document model.

Remarks

A consists of rows and cells, supports indexing (by row and by row/column pair), styling (), optional captions and descriptions, zebra striping, and enumeration over both rows and cells. It corresponds to a <w:tbl> element in WordprocessingML and to <table> in HTML. Table TableStyle Tables are typically created with the constructor or one of the factory helpers (,,, ). constructor(int, int) FromDataTable(DataTable, bool, TableStyle) FromCsv(string, bool, char, TableStyle) FromEnumerable`(IEnumerable<`>, bool, TableStyle) FromStrings(IEnumerable<string>, string, TableStyle)

Examples

csharp
1// 1. Manual 2x2 table
2var table = new Table(2, 2);
3table[0, 0].AddText("Name");
4table[0, 1].AddText("Value");
5table[1, 0].AddText("Product");
6table[1, 1].AddText("VDocs");
7doc.AddTable(table);
8
csharp
1// 2. Table from a DataTable
2var dt = new DataTable();
3dt.Columns.Add("Name");
4dt.Columns.Add("Quantity", typeof(int));
5dt.Rows.Add("Widget", 10);
6dt.Rows.Add("Gadget", 5);
7var table = Table.FromDataTable(dt, includeHeaders: true);
8doc.AddTable(table);
9
csharp
1// 3. Table from a typed collection
2public record Product(string Name, decimal Price);
3var products = new[]
4{
5 new Product("Widget", 9.99m),
6 new Product("Gadget", 19.99m),
7};
8var table = Table.FromEnumerable(products, includeHeaders: true);
9doc.AddTable(table);
10
csharp
1// 4. Table from CSV
2var table = Table.FromCsv("data.csv", hasHeaderRow: true);
3doc.AddTable(table);
4

Constructors

Table()

Initializes a new instance of the class with no rows or columns. Table

Table(int row, int column)

Initializes a new with the specified number of rows and columns. Table

Properties

Caption

Gets or sets an optional caption displayed with the table, often used to label or title the content.

Description

Gets or sets an optional description that can be associated with the table, typically used for accessibility or metadata purposes.

Item

Gets or sets the table row at the specified row index.

Item

Gets or sets a specific table cell using row and column indices.

Rows

Gets all the table rows contained within this table.

Gets or sets the style applied to this table.

ZebraColor

Gets or sets zebra-striping color definitions for alternating row styling.

Methods

Creates a from a CSV file located at the specified path. Table

Creates a single-column from a sequence of strings. Table

Retrieves the cell located at the specified row and column indices.

Returns an enumerator that iterates through all table cells in row-major order.

Retrieves the row at the specified index.

Merges a group of cells defined by the start and end coordinates.

Removes the specified row from the table.

Replaces the content of a cell at the specified coordinates.

Returns an enumerator that iterates through the table cells.