I have previously generated PDF files using the “Generate Document” action node, but now I would like to generate an Excel-file that contains data from my app. I can only choose PDF as the document type in this action node, and I am wondering if it is possible to somehow make an Excel-file instead? If not, are there any other ways to generate an Excel-file from Appfarm?
Use the “Export data” action node and you will get a CSV. You can find all the information in the documentation and there’s also an example in the showroom.
Use an external library and export the Excel file with “Run code”. The advantage here is that you can build the file with different data sources and structure it the way you want. First, you need to add the excelJS as a Custom Header Tag under Environments.
(Script URL: https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.4.0/exceljs.min.js). Then you can create your file by using “Run code”. Here is an example of the function in “Run code”. Projects is the datasource and name, projectlead, startdate, state, costs, comment are properties of this datasource.
We need this in our app as well. Tested your suggested code, but I get an error. Seems like it is unable to find the imported library? Have experienced something similar @Simona ?
TypeError: Cannot read properties of undefined (reading ‘Workbook’)
I just tested that code as well, and it works like charm. Are you sure you have added that excelJS entry to the Custom Header Tags section of the Environment Config (in the correct environment(s))?
In my case, I just added that entry, and did a run code where I added a “projects” data source, and adjusted the properties to be included.
Regarding the change request for “Generate Excel File” it is on the roadmap for “mid 2025”.