CSV to Excel

Know the component and how to use it.

Erick Rubiales avatar
Written by Erick Rubiales
Updated over a week ago

IMPORTANT: This documentation has been discontinued. Read the updated CSV to Excel documentation on our new documentation portal.

CSV to Excel transforms CSV-format files into XLSX files.

You can generate only 1 Excel file per execution.

Take a look at the configuration parameters of the component:

  • Multiple Sheets: if “true”, multiple CSV files will result in multiple sheets; otherwise, only 1 Excel file will be created.

  • Excel File Name: name of the file to be saved - if the field is empty, the "fileName" property will be considered.

  • Maximum File Size: maximum size allowed for the file (in bytes).

  • Charset: name encoding for the file reading - check more about java.nio.charset.Charset.

  • CSV File Name: name of the file or full file path (eg.: tmp/processed/file.txt) - Double Braces expressions are supported.

  • Sheet Name: name of the Excel sheet - if the field is empty, the sheet will be saved as "Sheet1".

  • Delimiter: delimiter in which the CSV is configured.

  • Fail On Error: if the option is enabled, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.

Some of the parameters above accept Double Braces. To understand how this language works, read our article by clicking here.

CSV to Excel in Action

Using multiple CSV files at once

You must enable the Multiple Sheets option so that it becomes possible to specify multiple CSV files in the generation of new sheets. This is for existing or non-existing Excel files.

If you need to create new sheets inside an existing Excel file, don't forget to inform the name of this file in the Excel File Name field. That way, the file is updated with the new sheets.


But if you want to create a new Excel file with these sheets, then don't fill the Excel File Name field (or fill it with the name of a non-existing file).

Using a CSV file

Insert the name of the CSV file to be used in the creation of a new sheet in the Excel File Name field.


If you need to create new sheets inside an existing Excel file, don't forget to inform the name of this file in the Excel File Name field. That way, the file is updated with the new sheets.


But if you want to create a new Excel file with these sheets, then don't fill the Excel File Name field (or fill it with the name of a non-existing file).

IMPORTANT: we don't advise the creation of a new sheet in an existing and big Excel file (with one or more sheets with a great amount of data), once it's necessary to open the whole Excel file to create the new sheets and that consumes a lot of memory. On the other hand, that doesn't happen when a new Excel file is created at once with multiple sheets - in this case, a stream is used in the creation process.

Configuration examples

1. The example you see below will result in the creation of a XLXS file and all the CSV columns and rows will be read as a string:

{
"type": "connector",
"name": "csv to excel-connector",
"stepName": "csv-test",
"params": {
"fileName": "{{message.fileName}}",
"excelFileName": "file",
"delimiter": ",",
"failOnError": false
}
}

2. See what the configuration types for some columns are:

{
"type": "connector",
"name": "csv to excel-connector",
"stepName": "csv-test",
"params": {
"fileName": "{{message.fileName}}",
"excelFileName": "file",
"cellDefinitions": "[{\" column \ ": \" A \ ", \" type \ ": \" NUMBER \ "}, {\" column \ ": \" B \ ", \" dateFormat \ " : \ "dd-MM-aaaa \", \ "type \": \ "DATE \"}, {\ "column \": \ "C \", \ "type \": \ "BOOLEAN \"}] ",
"delimiter": ",",
"failOnError": false
}
}


IMPORTANT: the manipulation of files inside a pipeline is made with all the protection. All the files can be accessed through one temporary directory only, where each pipeline KEY has access to its own set of files.

Did this answer your question?