Skip to content

Conversation

rstrlcpy
Copy link

Hello.

I'm trying to parse a XLSX file, but the parser does not parse sheet's data. I see workbook, i see sheet's name, but 'sheets' field is empty.

I did a research and found that 'parse_ws_xml_data' generates exception:

        /* 18.18.11 t ST_CellType */
        switch(p.t) {
          case 'n': p.v = parseFloat(p.v); break;
          case 's':
            sstr = strs[parseInt(p.v, 10)];                                                                                         
            p.v = sstr.t;
            p.r = sstr.r;
            if(opts.cellHTML) p.h = sstr.h;
            break;

exception on line 7495, because sstr is undefined, because 'p' contains only 't'.

I did a research of my file the cell (A1) that is causes exception has the following structure:

<row r="1" spans="1:9" customHeight="1" ht="35"><c r="A1" t="s"/><c r="B1" s="14" t="s"><v>0</v></c><c r="C1" s="1"/><c r="D1" s="1"/><c r="E1" s="1"/><c r="F1" s="1"/><c r="G1" s="1"/><c r="H1" s="1"/><c r="I1" s="1"/></row>

I tried to open the file by LibreOffice. Everything good. A1 cell does not contains anything.

I saved the opened file to other file. The new file was successfully parsed.

The first row in the new file does not have A1 cell.

<row collapsed="false" customFormat="false" customHeight="true" hidden="false" ht="35" outlineLevel="0" r="1"><c r="B1" s="1" t="s"><v>0</v></c><c r="C1" s="1"/><c r="D1" s="1"/><c r="E1" s="1"/><c r="F1" s="1"/><c r="G1" s="1"/><c r="H1" s="1"/><c r="I1" s="1"/></row>

The fix helps.

@protobi-pieter
Copy link
Collaborator

Thanks @ramzec ! Great catch. Rather than take this PR directly, I'll make the change to the relevant file in /bits/*.js and recompile.

@sarahkevinking
Copy link

sarahkevinking commented Oct 11, 2016

@pietersv did your change get merged in? I'm using v0.8.13 and I'm having a similar issue where cells of type s with no value defined cause the sheet to not be parsed.

This issue is especially troublesome when using a tool like https://github.com/tealeg/xlsx to generate xlsx files that are later parsed by js-xlsx.

@protobi-pieter
Copy link
Collaborator

  • Applied this change to the corresponding line on bits/67_wsxml.js
  • Bumped version number to 0.8.16
  • Ran make and make dist so that it regenerates xlsx.js on the root and dist/xlsx*.js
  • Merged in to the https://github.com/protobi/js-xlsx repo on the master branch.
  • Did NOT apply this to the https://github.com/protobi/js-xlsx#beta branch so this doesn't appear if you install by running npm install xlsx-style
  • Ran a few tests

saarCiklum pushed a commit to Folcon/js-xlsx that referenced this pull request Aug 13, 2020
RimaCiklum pushed a commit to RimaCiklum/js-xlsx that referenced this pull request Aug 17, 2020
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

Successfully merging this pull request may close these issues.

3 participants