Transforms internal representation into the Excel format.
-
Input:
List<Map<String, String>>— a list of rows, where each row is a map of column name to value. -
Output:
byte[]— the generated Excel file content. Returnsnullwhen usingfileToAppend(output is written directly to file).
Properties
|
Option |
Type |
Default |
Since |
Description |
|---|---|---|---|---|
|
|
Boolean |
|
IM 1.1.18 |
Indicates whether the input contains a header record (must be on the first row). |
|
|
Boolean |
|
IM 1.1.18 |
Determines whether to skip the header record in the output. |
|
|
String |
|
IM 1.1.18 |
Comma-separated list of headers from the input which should be present in the output. When set, only the specified columns are included. |
|
|
String |
|
IM 1.1.18 |
Sets the format of the output file. Options: |
|
|
Integer |
|
IM 1.1.18 |
Index of the sheet to write data to. |
|
|
String |
|
IM 1.1.18 |
Name of the sheet to write data to. If filled, takes precedence over |
|
|
String |
|
PFIMCORE-1876 (Feb 2024) |
Full path to an existing Excel file to append data to. When set, data is appended to the target file instead of creating a new one. Uses |
|
|
Enum |
|
IM 6.0.13 (PFIMCORE-2687, Oct 2025) |
Controls automatic data type conversion for cell values. |
Data Type Handling
|
Mode |
Behavior |
|---|---|
|
|
Attempts to parse each value as an integer. If successful, writes a numeric cell; otherwise writes a string cell. |
|
|
All values are written as string cells regardless of content. Useful when leading zeros or specific formatting must be preserved (e.g., SKU codes like |
Examples
Marshal data into Excel format (default)
<route>
<from uri="direct:start"/>
<setBody>
<groovy>[[sku: 'sku', name: 'name'], [sku: 10, name: 'BMW'], [sku: 20, name: 'AUDI']]</groovy>
</setBody>
<to uri="pfx-excel:marshal"/>
</route>
Marshal with dataConversionMode=NONE (preserve leading zeros)
<route>
<from uri="direct:start"/>
<setBody>
<groovy>[[sku: 00010, name: 'BMW'], [sku: 020, name: 'AUDI']]</groovy>
</setBody>
<to uri="pfx-excel:marshal?header=sku,name&hasHeaderRecord=false&dataConversionMode=NONE"/>
</route>
Append data to an existing Excel file
<route>
<from uri="direct:start"/>
<split>
<simple>${body}</simple>
<to uri="pfx-excel:marshal?fileToAppend=/tmp/output/result.xlsx"/>
</split>
</route>
Each split chunk is appended to the target file. The workbook state is preserved across splits and finalized when the last split is processed (Exchange.SPLIT_COMPLETE).
Common Pitfalls
-
Leading zeros lost — Default
AUTOmode converts00010to numeric10. UsedataConversionMode=NONEfor SKU codes, EAN codes, or any field where leading zeros matter. -
Large files with
fileToAppend— When usingfileToAppendinside asplit, the output body isnull(data is written directly to file). Do not chain further body-dependent steps after marshal. -
XLS vs XLSX — Default output format is
xlsx. If you needxlsfor legacy systems, setformat=xlsexplicitly.