Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xlsx file Open with issue Firefox only #139

Closed
charul2007 opened this issue Mar 31, 2015 · 4 comments
Closed

xlsx file Open with issue Firefox only #139

charul2007 opened this issue Mar 31, 2015 · 4 comments

Comments

@charul2007
Copy link

I am using excel-builder.js library to create the excel data and FileSaver.js to save this file.
Below is my code for saving:

testDataWorkbook.addWorksheet(testData);

saveAs(ExcelBuilder.createFile(testDataWorkbook, {
type: "blob"
}), "test.xlsx");

Which works just fine in chrome and IE.
The problem I am getting with Firefox is while doing "Open with" the file which gets created is
"test.xlsx.zip" which then throws a warning of different format than specified by the file extension.

Any help on the issue is much appreciated.

@eligrey
Copy link
Owner

eligrey commented Mar 31, 2015

Firefox might be checking magic numbers and overriding the mime type if it's a zip (xlsx is a zip file filled with a bunch of XML) even though there are zip-contained formats like the one you're using. I suggest that you also file this issue on https://bugzilla.mozilla.org/ and link to the issue here after filing it there, so I can keep up with the issue as well.

@davidda
Copy link

davidda commented Apr 10, 2015

I ran into the same issue and was able to resolve it. It is neither an issue with FileSaver nor Firefox. Firefox behaves correctly, because the file you are trying to save actually IS a zip file. ExcelBuilder just returns JSZip's output, which unsurprisingly has the zip mime type.

Try this instead:

var dataArray = ExcelBuilder.createFile(testDataWorkbook, {type: "uint8array"});
var blob = new Blob([dataArray], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
saveAs(blob, "test.xlsx");

@charul2007
Copy link
Author

Sorry for the delayed reply. I updated the excel export code to use the type: "uint8array". Works perfectly on FF/Chrome/IE. Thanks again.

@muhammadarshad60
Copy link

Hi,
anyone help me we used table to excel in jQuery .when table inside a table excel file get table and go to next row ...my issue is when we make table inside td excel file make table inside this td .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants