Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
Saving Excel Report returned from API call
-
I'm trying to save an excel report returned after calling
/rest/latest/excel-reports/download/{XID}
My first attempt doubles the file size so it looks like I'm saving bytes as chars.
saveExcelFile(data, report_filename) { let link = document.createElement("a"); let blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}) link.href = URL.createObjectURL(blob); link.download = report_filename; link.click(); URL.revokeObjectURL(link.href) link.remove(); }
The response payload looks to be base64 encoded but calling atob fails.
I've also played around with a string to array buffer function to convert the data which gives me the correct filesize but still not a completely correct conversion.
https://stackoverflow.com/questions/34993292/how-to-save-xlsx-data-to-file-as-a-blobA comparison of the hexdumps: (working file on left, file from original code snippet above on right)
From the hexdump I can see that the first ~49 bytes are are correct but then the encoding changes