Skip to main content

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) and rows (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:

  1. Validates the file descriptor and table data structure
  2. Retrieves the document from memory
  3. Calculates table dimensions (rows + 1 for header, columns)
  4. Creates the table with the specified style
  5. Populates the header row with column names
  6. Applies header formatting if enabled
  7. Fills data rows with values from the table object
  8. Adds spacing after the table if specified

Requirements

  • Valid file descriptor from Create Word or Open Word node
  • Table object with both columns and rows properties
  • 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 columns array
  • 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

  1. Data Preparation: Ensure your data is in the correct table format before passing to the node
  2. Column Names: Use clear, descriptive column names for the header row
  3. Styling Consistency: Use the same table style throughout a document for professional appearance
  4. Header Formatting: Enable Format Headers for better visual hierarchy
  5. Color Choices: Use dark colors (like "000000") for better readability
  6. Spacing: Add appropriate spacing after tables to separate them from other content
  7. Data Validation: Verify all row objects have the required column properties

Table Style Comparison

StyleBest ForVisual Appearance
Table GridSimple data, formal documentsBasic grid with black borders
Light GridModern reports, easy readingSubtle gray shading, lighter borders
Medium GridProfessional reportsBalanced 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

ErrorCauseSolution
"File Descriptor cannot be empty"No file descriptor providedEnsure Create Word or Open Word node runs first
"Invalid table data format"Table missing columns or rowsProvide table object with both columns and rows properties
"Table object with 'columns' and 'rows' arrays"Invalid table structureVerify table has correct structure with arrays
"Document not found"Invalid file descriptorCheck file descriptor matches the one from Create/Open Word
"Space after must be equal or greater than zero"Negative space valueUse 0 or positive number
"Failed to add table to document"Runtime errorVerify 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 NameHex CodeUse Case
Black000000Standard, professional
WhiteFFFFFFLight backgrounds only
Dark Blue1F4E78Corporate, professional
Navy000080Formal documents
Dark Green375623Financial reports
Dark Red8B0000Warnings, alerts
Dark Gray404040Subtle emphasis
Purple4B0082Creative documents