question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot open xlsx files created by XLSL.writeFile

See original GitHub issue

I’m trying to use js-xlsx to generate xlsl files for my Electron app. I followed the demo and can also create a xlsl file, here is the code:

const data = [
    ["Name", "Age", "Location"],
    ["Bob", 24, "NYC"],
    ["Jason", 30, "LA"]
];
const ws: XLSX.WorkSheet = XLSX.utils.aoa_to_sheet(data);
const wb: XLSX.WorkBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
XLSX.writeFile(wb, "SheetJS.xlsx");

Everything works fine before opening the generated file with Excel, when Excel warned me that the file cannot be opened, because of invalid file format or extesion. I’m not sure what’s wrong about my code, did I miss something?

Here’s how my development env goes:

  • OS: Window 10
  • Electron: 5.0.1
  • Angular: 7.2.15
  • xlsx: 0.15.0
  • Excel: Microsoft Office Professional Plus 2013

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
voxsoftwarecommented, Feb 27, 2021

I solved the problem with this XLSX.writeFile (wb," SheetJS.xls ");

When you write the file, the last line of your code, you must change XLSX.writeFile (wb," SheetJS.xlsx "); To XLSX.writeFile (wb, 'book.xls') In other words, change the format of the xlsx file to xls

This is not useful. Why use old format xls?

3reactions
mateombarcommented, Aug 21, 2020

I solved the problem with this XLSX.writeFile (wb," SheetJS.xls ");

When you write the file, the last line of your code, you must change XLSX.writeFile (wb," SheetJS.xlsx "); To XLSX.writeFile (wb, 'book.xls') In other words, change the format of the xlsx file to xls

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel cannot be open the file 'filename.xlsx' because the file ...
1) The file is not compatible with the MS Excel version. ... In Excel 2007, click the 'Microsoft Office' button and then 'Excel...
Read more >
Problematic corruption of .xlsx files with NPOI - Excel cannot ...
Problematic corruption of .xlsx files with NPOI - Excel cannot open the file 'file.xlsx" because the file format or file extension is not...
Read more >
Data Export | SheetJS Community Edition
The writeFile method packages the data and attempts to save the new file. The export file format is determined by the extension of...
Read more >
Why is there a permission error when repeat writing to excel file?
Unable to write to file 'RegressionResults.xlsx'. You may not have write permissions or the file may be open by another application.
Read more >
Python | Create and write on excel file using xlsxwriter module
Let's see how to create and write to an excel-sheet using Python. ... It cannot read or modify existing Excel XLSX files.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found