Summary: Reference for the pfx-excel Camel component — reading and writing Excel (XLSX) files in integration routes.
Source: https://pricefx.atlassian.net/wiki/spaces/IMDEV/pages/2006155328/pfx-excel+Component
Space: IM Doc in Progress (IMDEV)
Author: Michal Štěpán
Since: IM 1.1.18 (March 2020)
This component is used for easy Excel file manipulation. It supports reading (unmarshalling) and writing (marshalling) of both XLS and XLSX formats.
|
URI format |
|
|---|
Available Methods
|
Method |
Since |
Description |
|---|---|---|
|
|
IM 1.1.18 |
Converts internal representation (List of Maps) into an Excel file |
|
|
IM 1.1.18 |
Converts an Excel file (XLS/XLSX) into internal representation (List of Maps) |
|
|
IM 3.6 (Oct 2022) |
Streaming variant of unmarshal for large XLSX files with lower memory footprint |
pfx-excel:marshal
Source: pfx-excel:marshal
Last Modified: Oct 21, 2025
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 |
|
IM 5.3 (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 (Oct 2025) |
Controls automatic data type conversion for cell values. |
Data Type Handling
When writing cell values, the behavior depends on dataConversionMode:
|
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>
|
sku |
name |
|---|---|
|
10 |
BMW |
|
20 |
AUDI |
Marshal data without header record
<route>
<from uri="direct:start"/>
<setBody>
<groovy>[[sku: 10, name: 'BMW'], [sku: 20, name: 'AUDI']]</groovy>
</setBody>
<to uri="pfx-excel:marshal?header=sku,name&hasHeaderRecord=false"/>
</route>
|
sku |
name |
|---|---|
|
10 |
BMW |
|
20 |
AUDI |
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>
All values are written as strings — no numeric conversion is applied.
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 /tmp/output/result.xlsx. The workbook state is preserved across splits and finalized when the last split is processed (Exchange.SPLIT_COMPLETE).
pfx-excel:unmarshal
Source: pfx-excel:unmarshal
Last Modified: Aug 03, 2023
Transforms the given Excel file into internal structure.
-
Input:
InputStream— the Excel file content (XLS or XLSX). -
Output:
List<Map<String, String>>— a list of rows, where each row is a map of column name to value.
The format of the input (XLS vs XLSX) is automatically detected using Apache POI's FileMagic (stream-safe detection via mark/reset since IM 7.3.0).
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 to use. When |
|
|
Integer |
|
IM 1.1.18 |
Index of the sheet with the required data. |
|
|
String |
|
IM 1.1.18 |
Name of the sheet with the required data. If filled, takes precedence over |
Numeric Value Handling (since IM 7.2.0, March 2026)
Cell values are extracted with the following rules:
|
Cell Type |
Handling |
|---|---|
|
STRING |
Returned as-is |
|
BOOLEAN |
Converted to |
|
NUMERIC (whole number) |
Converted to long if within |
|
NUMERIC (decimal) |
Formatted using |
|
NUMERIC (NaN / Infinity) |
Returned as |
|
NUMERIC (date) |
Formatted as date string |
|
BLANK / OTHER |
Empty string |
Examples
Transform Excel file into internal representation (default)
The default configuration expects that the data resides in the first sheet (index 0) and contains a header row. Both XLS and XLSX formats are supported — the format is auto-detected.
<to uri="pfx-excel:unmarshal"/>
Given an Excel file with:
|
sku |
name |
|---|---|
|
10 |
BMW |
|
20 |
AUDI |
Output:
[[sku: 'sku', name: 'name'], [sku: '10', name: 'BMW'], [sku: '20', name: 'AUDI']]
Transform Excel file without header
When the Excel file has no header row, provide column names via the header parameter:
<to uri="pfx-excel:unmarshal?header=sku,name&hasHeaderRecord=false"/>
Output:
[[sku: '10', name: 'BMW'], [sku: '20', name: 'AUDI']]
Read from a specific sheet by name
<to uri="pfx-excel:unmarshal?sheetName=Products"/>
pfx-excel:streamingUnmarshal
Source: pfx-excel:streamingUnmarshal
Last Modified: Aug 03, 2023
Since: IM 3.6 (Oct 2022)
Transforms the given Excel file into internal structure in a fully streaming way.
-
Input:
InputStream— the Excel file content (XLSX only). -
Output:
Stream<Map<String, String>>— a lazy stream of rows for memory-efficient processing.
Key differences from unmarshal:
|
|
|
|
|---|---|---|
|
Format |
XLS and XLSX |
XLSX only |
|
Return type |
|
|
|
Memory footprint |
Full file loaded |
Substantially lower |
|
Use case |
Small to medium files |
Large files (thousands of rows) |
Properties
|
Option |
Type |
Default |
Since |
Description |
|---|---|---|---|---|
|
|
Boolean |
|
IM 3.6 |
Indicates whether the input contains a header record (must be on the first row). |
|
|
Boolean |
|
IM 3.6 |
Determines whether to skip the header record in the output. |
|
|
String |
|
IM 3.6 |
Comma-separated list of headers to use. Same behavior as in |
|
|
Integer |
|
IM 3.6 |
Index of the sheet with the required data. |
|
|
String |
|
IM 3.6 |
Name of the sheet with the required data. If filled, takes precedence over |
Limitations
-
XLSX only — XLS files cannot be streamed. Use
unmarshalfor XLS files. -
Streaming resources must be properly closed. The component handles cleanup automatically via
CleanupFunctioncallbacks inPfxExcelProducer.doStop().
Examples
Transform Excel file into internal representation streaming (default)
The default configuration expects that the data resides in the first sheet (index 0) and contains a header row. The input must be an XLSX file.
<to uri="pfx-excel:streamingUnmarshal"/>
Output:
[[sku: 'sku', name: 'name'], [sku: '10', name: 'BMW'], [sku: '20', name: 'AUDI']]
Stream large file and process in batches
<route>
<from uri="file:inbox?fileName=large-products.xlsx"/>
<to uri="pfx-excel:streamingUnmarshal"/>
<!-- body is now a Stream<Map<String, String>> — process lazily -->
<split streaming="true">
<simple>${body}</simple>
<to uri="direct:processRow"/>
</split>
</route>
Technical Notes
Supported Formats
|
Format |
Extension |
unmarshal |
streamingUnmarshal |
marshal |
|---|---|---|---|---|
|
OOXML (Office Open XML) |
|
Yes |
Yes |
Yes (default) |
|
OLE2 (Binary Excel) |
|
Yes |
No |
Yes ( |
Format auto-detection for unmarshal uses Apache POI's FileMagic — it peeks at the stream's first bytes via mark/reset without buffering the entire file (since IM 7.3.0, March 2026).
Streaming Library
The streaming reader library was updated from xlsx-streamer (monitorjbl) v2.2.0 to excel-streaming-reader (github.pjfanning) for Apache POI 5.x compatibility (IM 7.3.0, March 2026).
Version History
|
Version |
Date |
Change |
|---|---|---|
|
IM 1.1.18 |
March 2020 |
Initial component with |
|
IM 1.2 |
2020 |
Package refactoring |
|
IM 3.6 |
October 2022 |
Added |
|
IM 5.3 |
February 2024 |
Added |
|
IM 6.0.13 |
October 2025 |
Added |
|
IM 7.3.0 |
March 2026 |
Migrated to POI 5.x, replaced streaming library, improved format auto-detection via FileMagic |
|
IM 7.2.0 |
March 2026 |
Fixed scientific notation and numeric edge cases (NaN, Infinity, long overflow) in cell value extraction |