Export data from all sheets within a Flatfile Workbook into delimited text files and compress them into a single ZIP archive for download.
job:ready
event.
exportDelimitedZip
function.
Parameter | Type | Default | Description |
---|---|---|---|
job | string | 'downloadDelimited' | The job name that will trigger the export process. The listener will be configured to listen for workbook:${job} . |
delimiter | string | ',' | The character to use as a delimiter to separate values in the output files. For example, use ’,’ for CSV or ‘\t’ for TSV. |
fileExtension | string | 'csv' | The file extension to use for the generated delimited files (e.g., ‘csv’, ‘txt’, ‘tsv’). |
debug | boolean | false | When set to true, the plugin will print detailed logs to the console during its execution, which is useful for troubleshooting. |
workbook:downloadDelimited
. When triggered, it will process all sheets in the workbook, convert them to CSV files (using a comma delimiter), zip them up, and upload the final archive. Debug logging is disabled.
job:ready
event. When the specified job is executed, the plugin fetches all sheets in the workbook, streams their records, and writes them to local temporary files using the specified delimiter. These files are then added to a ZIP archive, which is uploaded to the Flatfile space. Finally, the temporary files and directory are cleaned up.
Parameters:
options
(PluginOptions) - An object containing configuration for the plugin
job
(string) - The job name to listen fordelimiter
(string) - The delimiter character for the output filesfileExtension
(string) - The file extension for the output filesdebug
(boolean, optional) - An optional flag to enable verbose console loggingFlatfileListener
plugin instance that can be passed to listener.use()
. The job itself, when completed successfully, returns an outcome
object to the Flatfile UI containing a message and a link to the generated ZIP file.
debug: true
configuration option. This will output detailed step-by-step logs to the console, including retrieved sheets, file paths, record counts, and any caught errors. This provides visibility into where the process might be failing.
debug
option to true
to see detailed error logs in the console where the listener is running.
The core logic is wrapped in a single try...catch
block. If an error occurs at any stage, it is caught, and the job is marked as failed with a general error message. Specific warnings are logged to the console if the cleanup of temporary files fails, but these do not cause the job to fail.
fs
) to create temporary files and directories.os.tmpdir()
). It attempts to clean these files up after the upload is complete, but in case of an unhandled crash, temporary files might be left behind.[<>:"/\\|?*]
) and replaces spaces with underscores.adm-zip
for creating ZIP archives and csv-stringify
for generating the delimited file content.