Chrome - strange file name with no file extension.
See original GitHub issueHi! I’m new to SheetJS and finally I have it working with html table -> excel exporting, but my files have strange names and no ‘xlsx’ ext.
` const workbook = XLSX.utils.table_to_book(table, { sheet: “regions” }); // Some data modifications here…
var options = { bookType: ‘xlsx’, bookSST: false, type: ‘base64’ };
XLSX.writeFile(workbook, “file.xlsx”, options); XLSX.writeFile(workbook, “file.xlsx”); `
I try different writeFile versions - with and without options, with file name taken from and hardcoded “file.xlsx”. After this code is done I have a file like “89eef6c4-3a5a-44f2-a512-61dad26bfdcf” in my Downloads folder (working on Ubuntu). If I rename it to “89eef6c4-3a5a-44f2-a512-61dad26bfdcf**.xlsx**” manually, I can open it via Excel or LibreOffice Calc and it contains my data. But I need it to take my file name and extension. What’s wrong in my code?
PS I saw this post https://github.com/SheetJS/js-xlsx/issues/1415, it doesn’t help.
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (5 by maintainers)
Top GitHub Comments
Added a note in the docs.
With the state of ESM in 2022, there’s no standard way for one module to depend on another module in a way that works in NodeJS ESM, in Deno Modules, in the web browser using
script type="module"
, and in tools like ViteJS and Webpack. The only techniques that currently work everywhere are “dependency injection” (like how we recommend loading the codepage tables) and “globals” (e.g. whatwriteFile
currently does)saveAs
was originally part of the “File API: Writer” proposed API for writing files in the web.Under the hood,
writeFile
will use that API if available.FileSaver.js adds
saveAs
to the global scope, which is why the library seems to work if you just import the dependencyWe’re unable to reproduce the overall issue locally. Any additional details (preferably a public demo) would help identify why it is not working in your deployment.