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

Non-mini xlsx.js missing "Root Entry" removal for proper ZIP parsing #1736

Open
shliama opened this issue Feb 16, 2020 Β· 4 comments
Open

Non-mini xlsx.js missing "Root Entry" removal for proper ZIP parsing #1736

shliama opened this issue Feb 16, 2020 Β· 4 comments

Comments

@shliama
Copy link

@shliama shliama commented Feb 16, 2020

There is a difference in safegetzipfile method between xlsx.js & xlsx.mini.js.

One is missing replace(/^Root Entry[\/]/,"") so I get this error "Cannot find file [Content_Types].xml in zip" every time trying to read a XLSX file πŸ€·β€β™‚οΈ

@SheetJSDev
Copy link
Contributor

@SheetJSDev SheetJSDev commented Feb 17, 2020

Thanks for reporting (and for the amusing commentary elsewhere :)

The xlsx.js script was not intended to be used on its own -- there are browser builds in the dist/ folder, and nodejs does something different that avoids the problem.

In particular, the mini build uses cfb for zip processing while the "full" build uses a modified jszip and assumes it exists. The CFB library presents a zip file like an OLE blob, with an implied root folder "Root Entry" even though it doesn't exist in the zip archive.

Fortunately there's an easy patch. The fix should be applied to https://github.com/SheetJS/sheetjs/blob/master/bits/21_ziputils.js#L32 :

-		var n = k[i].toLowerCase();
+		var n = (zip.FullPaths ? k[i].replace(/^Root Entry[\/]/,"") : k[i]).toLowerCase();
@tommy7420
Copy link

@tommy7420 tommy7420 commented Apr 18, 2020

erinn tjernagel

@Alebat
Copy link

@Alebat Alebat commented Apr 20, 2020

When will it be published?

@szilardd
Copy link

@szilardd szilardd commented May 23, 2020 β€’

I'm trying to develop a new functionality (excel taskpane add-in) and was also trying to use xlsx.js in a browser (because this is generated when building the project with make) and got a corruption error when opening the xlsx file.

If you include the jszip.js script before xlsx.js it works.

<script src="jszip.js"></script>
<script src="xlsx.js"></script>

Not sure if there is a different way to test changes in a browser? Haven't found a way to create a new browser build in the dist version.

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

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.