ToolJet/docs/versioned_docs/version-2.9.0/actions/generate-file.md
Nakul Nagargade 06b558c84a
Prevent app re-renders on hovering widgets in canvas (#7015)
* Move version manager editor states to zustand

* Update appDataStore to appVersionsManagerStore

* Move released version popup state to global

* Move isVersionReleased to global store

* Rename appVersionsManagerStore to appVersionStore and destructure zustand data inside components

* Move showComments and toggleComments states to zustand store

* Move current layout from editor local states to editor store

* Move hovered component to zustand

* Move selected components to zustand

* Merge branch 'refactor/zustand-edior-store' into zustand-editor-store-2

* Fix

* FIx

* Remove util function

* Reolve code comments

* Resolve code comments
2023-08-31 13:42:32 +05:30

1.6 KiB

id title
generate-file Generate file

Generate file

This action allows you to construct files on the fly and let users download it.

Options

Option Description
Type Type of file to be generated. Types: CSV and Text
File name Name of the file to be generated
Data Data that will be used to construct the file. Its format will depend on the file type, as specified in the following section
Debounce Debounce field is empty by default, you can enter a numerical value to specify the time in milliseconds after which the action will be performed. ex: 300

:::tip Check how to run generate file action using RunJS. :::

CSV Data Format

To use the CSV file format, the data field should contain an array of objects. ToolJet assumes that the keys in each object are the same and represent the column headers of the CSV file.

Example:

{{
  [
    { name: 'John', email: 'john@tooljet.com' },
    { name: 'Sarah', email: 'sarah@tooljet.com' },
  ]
}}

Using the above code snippet will generate a CSV file with the following content:

name,email
John,john@tooljet.com
Sarah,sarah@tooljet.com

Text Data Format

To use the Text file format, the data field should contain a string.

If you want to generate a text file based on an array of objects, you need to stringify the data before providing it.

For example, if you are using the table component to provide the data, you can enter {{JSON.stringify(components.table1.currentPageData)}} in the Data field.