CSV import & export
Last updated
Was this helpful?
Last updated
Was this helpful?
UI Bakery allows importing CSV files to your app and, for example, displaying them in a Table. Let's review how you can do that.
Add the File picker component to the working area.
File picker component has a special property – parsedValue. It allows you to access the CSV file content as an array of objects without uploading it to the server or parsing it separately.
In component's settings, select the Parse file checkbox to allow the system to access file content.
Next, select the file you want to upload in the File picker.
Now, add the Table component and reference File picker using {{ui.filepicker.parsedValue}}
.
Click Regenerate structure.
Done! Your CSV file content will now be displayed in the Table.
Along with importing data, you can also as easily export it from your app in a CSV format. In this section, we'll review two ways how you can do that - using a built-in export button (for the Table component) and using an action to generate a CSV file.
Table component in UI Bakery has a built-in button to directly download data in a CSV format. You simply need to click it and your exported file will be automatically downloaded.
In this case, you can use an action consisting of two steps, where the first step is an API or database request. Follow the steps below to see the whole flow:
Create a new action that will consist of two steps:
First step - HTTP Request action where you need to specify your URL (it should return an array of objects).
Second step - Generate File action where you need to reference the result of the previous step as {{data}}
variable in the Generate from field.
Click Execute action.
Your exported file will be automatically downloaded to your default Downloads folder.
UI Bakery also allows exporting data to other formats, not only to CSV. You simply need to use a JavaScript Code action step to achieve this. Check out the code snippets below👇
To export data to .txt:
To generate JSON file from previous data:
For multipart requests: