.xlsx file corrupt on download from express server but works fine on localhost server
See original GitHub issueSo, I’m having this problem that whenever I’m downloading data(json) as .xlsx file its getting corrupted and unusable, this is the case when this app is deployed on heroku using express server. But when I run a local server on my machine and download the file it works just fine and data is there the way I want.
I’m using XLSX version 0.11.3 and on client side only.
Here’s the code:
downloadResData(data) {
let ws = XLSX.utils.json_to_sheet(data);
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "data");
let wbout = XLSX.write(wb, {bookType: 'xlsx', type: 'binary'});
function s2ab(s) {
let buf = new ArrayBuffer(s.length);
let view = new Uint8Array(buf);
for (let i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
FileSaver.saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "data.xlsx");
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
xlsx file corrupt on download from express server but works ...
So, I'm having this problem that whenever I'm downloading data(json) as .xlsx file its getting corrupted and unusable, this is the case when ......
Read more >getting corrupt file while trying to download excel(.xlsx) ...
My goal is to send excel (.xlsx) file to the client and download the excel file. Below is my server side code which...
Read more >IIS 10 corrupts Excel file on download
I have an ASP.Net MVC application that exports data to an Excel workbook; an .xlsx file. The workbook is generated correctly on the...
Read more >MS Excel corrupt after upload into Azure Blob Storage
Hi Team, I am trying to upload an MS Excel (.xlsx) file via Shared Access Signature (SAS) into a Azure Blob Storage.
Read more >Express-Server with Netlify functions - Support
My approach on this was: setting up an Express-server (locally tested - it works fine! - result: download of customized xlsx-file as expected);...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Finally, fixed the issue. The problem was with the
browserify
package. The version I was using was way too old, I updated it to the latest one and got rid of the corrupted downloads.Copy and paste that string into your application and store it as some variable (like
datajson
) then hardcodedownloadResData(JSON.parse(datajson))
and see if the problem shows up locally.