Add Table
Adds a formatted table to a Word document.
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.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- File Descriptor - Unique identifier of the document to add the table to. This comes from the Create Word or Open Word node. Default variable is
{{$message.word_fd}}. - Table - Table data object containing columns and rows. Must be a valid data table object with
columns(array of column names) androws(array of row objects). - Space After - Space after the table in points. Default is 0. Use values like 12, 18, or 24 to add spacing after the table.
Options
- Table Style - Visual style for the table. Options:
- Table Grid - Simple grid with borders (default)
- Light Grid - Light gray alternating rows
- Medium Grid - Medium shading with styled borders
- Format Headers - Whether to apply bold formatting and color to header row. Default is false.
- Header Color - Header text color in hex format (e.g., "000000" for black, "FFFFFF" for white, "FF0000" for red). Only applies when Format Headers is enabled. Default is "000000" (black).
How It Works
The Add Table node creates a formatted table with data from a table object. When executed, the node:
- Validates the file descriptor and table data structure
- Retrieves the document from memory
- Calculates table dimensions (rows + 1 for header, columns)
- Creates the table with the specified style
- Populates the header row with column names
- Applies header formatting if enabled
- Fills data rows with values from the table object
- Adds spacing after the table if specified
Requirements
- Valid file descriptor from Create Word or Open Word node
- Table object with both
columnsandrowsproperties - Non-negative space after value
- Valid hex color code for header color (6 characters)
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid file descriptor
- Document not found
- Invalid table data format (missing columns or rows)
- Table data is not an object
- Space after is negative
- Invalid header color format
Usage Examples
Example 1: Add Sales Data Table
Scenario: Add a table with monthly sales data
// Create sales data table
$local.salesTable = {
columns: ["Month", "Revenue", "Expenses", "Profit"],
rows: [
{ Month: "January", Revenue: "$50,000", Expenses: "$30,000", Profit: "$20,000" },
{ Month: "February", Revenue: "$55,000", Expenses: "$32,000", Profit: "$23,000" },
{ Month: "March", Revenue: "$60,000", Expenses: "$35,000", Profit: "$25,000" }
]
};
Configuration:
- File Descriptor:
{{$message.word_fd}} - Table:
{{$local.salesTable}} - Space After:
12 - Table Style:
Medium Grid - Format Headers:
true - Header Color:
000000
Example 2: Add Customer List
Scenario: Add a simple customer list with contact information
// Create customer table from data
$local.customers = {
columns: ["Company", "Contact", "Email", "Phone"],
rows: [
{
Company: "Acme Corp",
Contact: "John Smith",
Email: "john@acme.com",
Phone: "(555) 123-4567"
},
{
Company: "Tech Solutions",
Contact: "Jane Doe",
Email: "jane@techsol.com",
Phone: "(555) 987-6543"
}
]
};
Configuration:
- File Descriptor:
{{$message.word_fd}} - Table:
{{$local.customers}} - Space After:
18 - Table Style:
Light Grid - Format Headers:
true - Header Color:
1F4E78
Example 3: Add Table from Database Query
Scenario: Add a table with data from a database query
// Assume $message.query_result contains data from a database
// Transform to table format
$local.reportTable = {
columns: ["ID", "Product", "Quantity", "Status"],
rows: $message.query_result.map(item => ({
ID: item.id,
Product: item.product_name,
Quantity: item.quantity.toString(),
Status: item.status
}))
};
Configuration:
- File Descriptor:
{{$message.word_fd}} - Table:
{{$local.reportTable}} - Space After:
0 - Table Style:
Table Grid - Format Headers:
false
Usage Notes
- Tables are always added at the end of the document
- Column order in the table matches the order in the
columnsarray - Each row object must have properties matching the column names
- Missing values in row objects will appear as empty cells
- The table automatically adjusts column widths to fit content
- Multiple tables can be added to the same document
Tips for Effective Use
- Data Preparation: Ensure your data is in the correct table format before passing to the node
- Column Names: Use clear, descriptive column names for the header row
- Styling Consistency: Use the same table style throughout a document for professional appearance
- Header Formatting: Enable Format Headers for better visual hierarchy
- Color Choices: Use dark colors (like "000000") for better readability
- Spacing: Add appropriate spacing after tables to separate them from other content
- Data Validation: Verify all row objects have the required column properties
Table Style Comparison
| Style | Best For | Visual Appearance |
|---|---|---|
| Table Grid | Simple data, formal documents | Basic grid with black borders |
| Light Grid | Modern reports, easy reading | Subtle gray shading, lighter borders |
| Medium Grid | Professional reports | Balanced shading with styled borders |
Best Practices
- Consistent Data Types: Ensure all values in a column are the same type (all strings or all numbers)
- String Conversion: Convert numbers to strings when needed for display formatting
- Empty Rows: Avoid empty rows in your data - they create blank table rows
- Large Tables: For very large tables, consider splitting across multiple tables
- Header Colors: Choose colors that contrast well with white backgrounds
- Professional Colors: Common header colors:
- Black: "000000"
- Dark Blue: "1F4E78"
- Dark Green: "375623"
- Dark Gray: "404040"
Table Data Structure
The table object must follow this structure:
{
columns: ["Column1", "Column2", "Column3"], // Array of column names
rows: [ // Array of row objects
{ Column1: "value1", Column2: "value2", Column3: "value3" },
{ Column1: "value4", Column2: "value5", Column3: "value6" }
]
}
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| "File Descriptor cannot be empty" | No file descriptor provided | Ensure Create Word or Open Word node runs first |
| "Invalid table data format" | Table missing columns or rows | Provide table object with both columns and rows properties |
| "Table object with 'columns' and 'rows' arrays" | Invalid table structure | Verify table has correct structure with arrays |
| "Document not found" | Invalid file descriptor | Check file descriptor matches the one from Create/Open Word |
| "Space after must be equal or greater than zero" | Negative space value | Use 0 or positive number |
| "Failed to add table to document" | Runtime error | Verify all row objects have properties matching column names |
Converting Data to Table Format
From Array of Objects
// Original data
$local.data = [
{ name: "John", age: 30, city: "New York" },
{ name: "Jane", age: 25, city: "Boston" }
];
// Convert to table format
$local.table = {
columns: ["Name", "Age", "City"],
rows: $local.data.map(item => ({
Name: item.name,
Age: item.age.toString(),
City: item.city
}))
};
From CSV Data
// Assuming CSV has been parsed to array
$local.csvData = [
{ Product: "Widget", Price: "10.00", Stock: "100" },
{ Product: "Gadget", Price: "15.00", Stock: "50" }
];
// Already in compatible format
$local.table = {
columns: ["Product", "Price", "Stock"],
rows: $local.csvData
};
Hex Color Reference
| Color Name | Hex Code | Use Case |
|---|---|---|
| Black | 000000 | Standard, professional |
| White | FFFFFF | Light backgrounds only |
| Dark Blue | 1F4E78 | Corporate, professional |
| Navy | 000080 | Formal documents |
| Dark Green | 375623 | Financial reports |
| Dark Red | 8B0000 | Warnings, alerts |
| Dark Gray | 404040 | Subtle emphasis |
| Purple | 4B0082 | Creative documents |