The Microsoft Excel Writer step writes incoming rows into an MS Excel file. It supports both the xls and xlsx file formats. The xlsx format is usually a good choice when working with template files, as it is more likely to preserve charts and other misc objects in the output. The proprietary (binary) xls format is not as well understood and deciphered, so moving/replicating nontrivial xls content in non-MS software environments is usually problematic.
The file section allows to choose the result filename and extension, possibly including file generation timestamp information. Use the Show filename(s) button to preview see the resulting filename(s). Multiple files will be created if the split data every x rows option is used.
Stream XLSX data: Check this option when writing large XLSX files. It uses internally a streaming API and is able to write large files without any memory restrictions (of course not exceeding Excel's limit of 1,048,575 rows and 16,384 columns). Note: This option is available since version 4.4.0.
If output file exists: choose what the step should do if it finds that the output file exists already. You may choose to reuse the existing file, or create a new one.
Wait for first row before creating file : Checking this option makes the step create the file only after it has seen a row. If this is disabled the output file is always created, regardless of whether rows are actually written to the file.
Add filename(s) to result: Check to have the filename added to the result filenames
Sheet Name: The sheet name the step will write rows to.
Make this the active sheet: If checked the Excel file will by default open on the above sheet when opened in MS Excel.
If sheet exists in output file : the output file already has this sheet (for example when using a template, or writing to existing files), you can choose to write to the existing sheet, or replace it.
Protect Sheet: The XLS file format allows to protect an entire sheet from changes. If checked you need to provide a password. Excel will indicate that the sheet was protected by the user you provide here.
When creating new files (when existing files are replaced, or completely fresh files are created) you may choose to create a copy of an existing template file instead. Please make sure that the template file is of the same type as the output file (bot must be xls or xlsx respectively).
When creating new sheets, the step may copy a sheet from the current document (the template or an otherwise existing file the step is writing to). A new sheet is created if the target sheet is not present, or the existing one shall be replaced as per configuration above.
Start writing at cell: This is the cell to start writing to in Excel notation (letter column, number row)
When writing rows : the step may overwrite existing cells (fast), or shift existing cells down (append new rows at the top of sheet)
Write Header: if checked the first line written will contain the field names
Write Footer: if checked the last line written will contains the field names
Auto Size Columns: if checked the step tries to automatically size the columns to fit their content. Since this is not a feature the xls(x) file formats support directly, results may vary.
Force formula recalculation: if checked, the step tries to make sure all formula fields in the output file are updated.
- The xls file format supports a "dirty" flag that the step sets. The formulas are recalculated as soon as the file is opened in MS Excel.
- For the xlsx file format, the step must try to recalculate the formula fields itself. Since the underlying POI library does not support the full set of Excel formulas yet, this may give errors. The step will throw errors if it cannot recalculate the formulas.
Leave styles of existing cells unchanged: if checked, the step will not try to set the style of existing cells it is writing to. This is useful when writing to pre-styled template sheets.
Start writing at end of sheet: The step will try to find the last line of the sheet, and start writing from there.
Offset by ... rows: any non-0 number will cause the step to move this amount of rows down (positive numbers) or up (negative numbers) before writing rows. Negative numbers may be useful if you need to append to a sheet, but still preserve a pre-styled footer.
Begin by writing ... empty lines: the step will write some empty lines before starting to write data. This is useful if you want to append to a sheet, but leave a couple of lines clear between data tables.
Omit Header: if checked the header will not be written when the step is appending lines, even if it is enabled in the content options section.
The fields table configures the output columns in the excel document.
Name: the field to write
Type: the type of data
Format: the Excel format to use in the sheet. Please consult the Excel manual for valid formats. There are some online references as well.
Style from cell: a cell (i.e. A1, B3 etc.) to copy the styling from for this column (usually some pre-styled cell in a template)
Field Title: if set, this is used for the Header/Footer instead of the kettle field name
Header/Footer style from cell: a cell to copy the styling from for headers/footers (usually some pre-styled cell in a template)
Field Contains Formula: set to Yes, if the field contains an Excel formula (no leading '=')
Hyperlink: a field, that contains the target to link to. The supported targets are Link to other cells, http, ftp, email, and local documents
Cell Comment / Cell Author: The xlsx format allows to put comments on cells. If you'd like to generate comments, you may specify fields holding the comment and author for a given column.
You can use the Metadata Injection supported fields with ETL Metadata Injection step to pass metadata to your transformation at runtime. The following Value fields of the Microsoft Excel Writer step support metadata injection:
- Name, Type, Format, Style from Cell, and Field Title
The samples package contains several demo transformations that showcase the features of the step, including templates, formulas, links, comments etc.