XLSX.readFile returns object with no SheetNames and no data. + patch #191
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#191
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi!
I tried to read a xlsx file and no data was returned, I'm working with nodejs. I debugged the xslx.js and found some solution for me, I'd like to share;-)
1st Problem was function parse_zip(zip, opts)
Line 5007:
-if(!props.Worksheets) { //props.Worksheets was 1 and props.SheetNames.length was 0
+if(!props.Worksheets || props.SheetNames.length === 0) { //works for me
Without SheetNames, safe_parse_ws(zip, path, relsPath, props.SheetNames[i], sheetRels, sheets, opts) would fail.
2nd Problem was the mergeCell tag in my file. It has a closing tag .
I changed line 2835:
-var mergecregex = /<mergeCell ref="[A-Z0-9:]+"\s_/>/g;
+var mergecregex = /<mergeCell ref="[A-Z0-9:]+"\s_(/|)>/g;
and it worked for me.
With my 2 patches it can read the data correct.
Is this helpfull for you?
@chk- do you have a sample file to add to the test suite?
I organized a testfile to provide to you, but how do I add it to the test suit?
@chk- easiest way is to just email it to ---------
So I did.
I am facing the same issue with xlsx workbook, After making the changes suggested by @chk- I am able to get the worksheet name but still no data is parsed. Do we have fix for the issue available.
@imsaquib
Please notice my change on the regular expression for the var mergecregex. In the original code it needs a closing tag. I changed it to make the closing tag optional. Maybe there are other regex's explizit wanting a closing tag. If so, please try again after making the closing tag optional.
@SheetJSDev I suggest changing all regex's to make the closing tag optional.
@chk- Thanks for the reply, Had to make closing tag optional for hlinkregex to parse the file.
But by doing so lost the formatted values ""C21":{"t":"n","v":491341.285099999}" & Hyperlink information.
@imsaquib Maybe I could create a better regular expression for that, but I would need a sample file from you. How does a hlink tag look like in your file? In my case, the mergecell tag had no closing tag, so no information was lost.
@chk- The mergecells & hyperlinks inmy sample xlsx looks like:
@chk- @imsaquib Incidentally the same issue was discovered by @oising a while back. We ended up going through and fixing a bunch of them in an unreleased change.
For the hyperlink case, regarding the assumption that the tags are singletons (not open/close), the relevant section of the specification is ECMA-376 18.3.1.47 hyperlink. It points to the type
CT_Hyperlink
which has no child. This is the snippet from the schema:Ok so it looks like Excel doesn't actually care. We will change these and a few other tags