Get Started
Documentation

CreateTable

CreateTable(nCols, nRows) → {ApiTable}

Create a new table with a specified number of rows and columns.

Parameters:

Name Type Description
nCols number Number of columns.
nRows number Number of rows.

Returns:

Type
ApiTable

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oTable;
oTable = Api.CreateTable(3, 3);
oDocument.Push(oTable);
oTable.SetTableBorderTop("single", 32, 0, 0, 0, 255);
oTable.SetTableBorderBottom("single", 32, 0, 0, 0, 255);
oTable.SetTableBorderLeft("single", 32, 0, 0, 0, 255);
oTable.SetTableBorderRight("single", 32, 0, 0, 0, 255);
oTable.SetTableBorderInsideV("single", 32, 0, 255, 0, 0);
oTable.SetTableBorderInsideH("single", 32, 0, 255, 0, 0);
oTable.SetWidth("percent", 100);
builder.SaveFile("docx", "CreateTable.docx");
builder.CloseFile();

Resulting document