Overview
This node, named "Excel By Template," allows users to generate Excel files based on an existing template file. It reads a specified Excel template and populates rows starting from a given row number with data from the input items. Users can configure which columns in the Excel sheet correspond to which properties of the input data, effectively mapping input JSON fields into specific Excel columns.
Common scenarios where this node is beneficial include:
- Generating reports or invoices by filling predefined Excel templates with dynamic data.
- Automating the creation of Excel documents that follow a strict format.
- Populating Excel sheets for further processing or distribution without manual editing.
For example, if you have an invoice template Excel file, you can use this node to fill customer names, product details, and prices into designated columns starting at a specific row, producing a ready-to-use invoice document.
Properties
Name | Meaning |
---|---|
Template File | Path to the Excel template file to be used as the base for generating the output Excel file. |
Start Row | The row number in the Excel worksheet where data population should begin (minimum 1). |
Columns | Configuration of columns to populate: a collection of mappings specifying which property from the input data goes into which column index in the Excel sheet. Each entry includes: - Index: The column number in the Excel sheet (starting at 1). - Property: The name of the property from the input JSON data to insert into that column. |
Output
The node outputs a single item containing binary data representing the generated Excel file. The binary data is accessible under the binary.data
field and contains the complete Excel file created by filling the template with the input data.
The json
output field is empty ({}
) since the main output is the binary Excel file.
Dependencies
- Requires the
exceljs
library to read and write Excel files. - Uses the
uuid
package to generate a unique filename for the temporary Excel file. - Access to the filesystem (
fs
) to read the template file and clean up temporary files. - The user must provide a valid path to an existing Excel template file accessible by the node.
Troubleshooting
Error: "no configuration columns"
This error occurs if no columns are configured in the "Columns" property. Ensure that at least one column mapping is defined with both the column index and the property name.Error: "no worksheet"
This indicates that the template Excel file does not contain any worksheets or the first worksheet could not be accessed. Verify that the template file is a valid Excel file with at least one worksheet.File access errors
If the node cannot read the template file, check that the file path is correct and accessible by the n8n process.Data mapping issues
If the specified property does not exist in the input data, the corresponding cell will be set to the property name string literally. Make sure the property names match those in the input JSON.Continue On Fail behavior
If enabled, the node will continue processing subsequent items even if an error occurs for one item, appending error information to the output.
Links and References
- ExcelJS GitHub Repository – Library used for Excel file manipulation.
- UUID Package – Used for generating unique filenames.
- n8n Documentation on Binary Data – How binary data is handled in n8n nodes.