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.

Chrome - strange file name with no file extension.

See original GitHub issue

Hi! 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:closed
  • Created 4 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
SheetJSDevcommented, Oct 20, 2022

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. what writeFile currently does)

1reaction
SheetJSDevcommented, Oct 20, 2022

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 dependency

We’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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome doesn't always add file extension to downloaded ...
So my questions are: Why does my browser not always store images with an extension? Why that weird behavior when cropping images? My...
Read more >
save files without file extension automatically being added to ...
Strangely, I noticed that even when I UNchecked the "Show all filename extensions" option, none of my file extensions disappeared.
Read more >
Chrome file upload bug: file name goes wrong when choose ...
I am working on a simple web page with a file upload control: <input type="file" name="file">. And when I test it, I find...
Read more >
Disabling Google Chrome Download auto numbering for ...
But Chrome suggests a name for the file and if it already exists, it adds (N) . You can see that when you...
Read more >
What's with all the cache/nocache stuff and weird filenames?
During its bootstrap process, a Google Web Toolkit application goes through a series of sometimes oddly-named files. These files, generated by the GWT ......
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