Add Table
Adds a table to the Word document with data from a Table object. The table is formatted with borders and can optionally display headers with special formatting.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing the node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
-
File Descriptor - File descriptor ID from the Open Word node. Default variable is
word_fd. -
Table - Table object containing columns and rows data. Default variable name is
table. The table object structure:{
"columns": ["Column1", "Column2", "Column3"],
"rows": [
{"Column1": "Value1", "Column2": "Value2", "Column3": "Value3"},
{"Column1": "Value4", "Column2": "Value5", "Column3": "Value6"}
]
} -
Space After - Space in points to add after the table (0 or greater). Common values:
6,12,18.
Options
- Headers - Whether to format the first row as headers with bold red text. Default is
false.true- First row displayed with bold, red formattingfalse- First row displayed with normal formatting
Use Cases
- Inserting data tables into reports and documents
- Displaying database query results in Word format
- Creating formatted price lists or product catalogs
- Adding comparison tables or feature matrices
- Generating invoices or itemized lists
- Building financial reports with tabular data
Example
Creating a simple employee table:
// Prepare table data
let employeeTable = {
"columns": ["Name", "Department", "Position"],
"rows": [
{"Name": "John Smith", "Department": "Sales", "Position": "Manager"},
{"Name": "Jane Doe", "Department": "Marketing", "Position": "Director"},
{"Name": "Bob Johnson", "Department": "IT", "Position": "Developer"}
]
};
// Add to Word document
// File Descriptor: word_fd
// Table: employeeTable
// Space After: 12
// Headers: true
Creating Tables from Different Data Sources
From Array of Objects
// Source data: array of objects
let products = [
{name: "Laptop", price: 999, stock: 15},
{name: "Mouse", price: 25, stock: 50},
{name: "Keyboard", price: 75, stock: 30}
];
// Convert to table format
let table = {
"columns": ["name", "price", "stock"],
"rows": products
};
From CSV or Excel Data
// Assuming you've read data from Excel/CSV
// columns: ["Product", "Quantity", "Price"]
// rows: [{Product: "Item1", Quantity: 10, Price: 50}, ...]
let table = {
"columns": columns,
"rows": rows
};
Simple 2-Column Table
let configTable = {
"columns": ["Setting", "Value"],
"rows": [
{"Setting": "Server", "Value": "production.example.com"},
{"Setting": "Port", "Value": "8080"},
{"Setting": "Protocol", "Value": "HTTPS"}
]
};
Complex Example: Sales Report Table
// Create a sales report table
let salesData = {
"columns": ["Region", "Q1 Sales", "Q2 Sales", "Q3 Sales", "Q4 Sales", "Total"],
"rows": [
{
"Region": "North",
"Q1 Sales": "$125,000",
"Q2 Sales": "$150,000",
"Q3 Sales": "$175,000",
"Q4 Sales": "$200,000",
"Total": "$650,000"
},
{
"Region": "South",
"Q1 Sales": "$100,000",
"Q2 Sales": "$110,000",
"Q3 Sales": "$120,000",
"Q4 Sales": "$130,000",
"Total": "$460,000"
},
{
"Region": "East",
"Q1 Sales": "$90,000",
"Q2 Sales": "$95,000",
"Q3 Sales": "$100,000",
"Q4 Sales": "$105,000",
"Total": "$390,000"
},
{
"Region": "West",
"Q1 Sales": "$110,000",
"Q2 Sales": "$115,000",
"Q3 Sales": "$120,000",
"Q4 Sales": "$125,000",
"Total": "$470,000"
}
]
};
Enable the Headers option to make the first row stand out with bold red text. This is useful for tables where column names should be visually distinct from data.
Table Formatting
- Tables include borders on all cells (inside and outside lines)
- Tables use Word's auto-fit feature for column sizing
- Header row (when enabled) uses:
- Bold text
- Red color (WdColor.wdColorRed)
- All other cells use default black text
Common Errors
- "Invalid File Descriptor" - Ensure the Open Word node was executed first.
- "Space After must be equal to or greater than zero" - Use a non-negative value.
- Invalid table structure - Ensure the table object has both
columnsandrowsproperties. - Column mismatch - All row objects must have properties matching the column names.
Notes
- The table is inserted at the end of the document.
- Column names in the
columnsarray must exactly match the property names in row objects. - The table automatically adjusts column widths based on content.
- Empty cells are supported by providing empty string values.
- All values are converted to strings when inserted into the table.
Best Practices
- Keep column names short for better table readability.
- Use consistent data types within each column.
- Pre-format numeric values (currency, decimals) as strings before creating the table.
- For large tables, consider splitting into multiple tables for better readability.
- Use the Headers option for tables where the first row represents column names.
See Also
- Add Text - Add text paragraphs
- Add Heading - Add section headings
- Add Image - Add images