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.

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

See original GitHub issue

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 🤷‍♂️

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Alebatcommented, Apr 20, 2020

When will it be published?

1reaction
SheetJSDevcommented, 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();
Read more comments on GitHub >

github_iconTop Results From Across the Web

xlsx - npm
"Utility Functions" details utility functions for translating JSON Arrays and other common JS structures into worksheet objects. The Zen of ...
Read more >
Date in XLSX file not parsing correctly in SheetJs
It is changing the year format. My requirement is to get the data as it is. Sample Code: var workbook = XLSX.readFile( ...
Read more >
Parsing Options - SheetJS Community Edition
XLSX.read(data, read_opts) attempts to parse data. ... type, Input data encoding (see Input Type below). raw, false, If true, plain text parsing will...
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