In my app I have a query that retrieves an Excel file from API and a JS Code action that calls utils.downloadFile
to download it. The query seems to work correctly and sets its data
property as follows
I tried downloading the retrieved file as follows:
utils.downloadFile(generate_spreadsheet.data, "spreadsheet", "xslx")
but instead of an Excel file, I get a JSON object. I also tried passing base64Binary as follows:
obj = {
base64Binary: generate_spreadsheet.data.base64Data,
}
utils.downloadFile(obj, "spreadsheet", "xslx")
This time I got a correct Excel file, except that my system recognizes it as a zip archive instead. I also tried adding type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
to the object passed to downloadFile
but it didn't change anything. When I call the endpoint using curl, I get a correct and properly recognized Excel file. How can I replicate this behavior in Retool?
EDIT: so, if anyone stumbles upon this thread, it turns out I made a typo in the extension, correcting it to "xlsx" makes the file correctly recognized.