[go: nahoru, domu]

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

Try to handle the case where a <c> element is missing an r attribute #537

Merged
merged 1 commit into from
Apr 13, 2018

Conversation

papandreou
Copy link
Contributor
@papandreou papandreou commented Apr 9, 2018

I've run into an Excel spreadsheet where some <c> elements do not have address references. It looks like it's some kind of shorthand where it's implicitly the next cell, and Excel opens the spreadsheet fine. Here's a pretty-printed snippet from the spreadsheet:

  <sheetData>
    <row r="1" spans="1:1" ht="18" customHeight="1">
      <c r="A1" s="1" t="s">
        <v>0</v>
      </c>
    </row>
    <row r="2" spans="1:1" ht="12.75" customHeight="1">
      <c r="A2" s="2" t="s">
        <v>1</v>
      </c>
    </row>
    <row r="3" spans="1:1" ht="12.75" customHeight="1">
      <c r="A3" s="2" t="s">
        <v>2</v>
      </c>
    </row>
    <row r="5" spans="1:12" ht="12.75" customHeight="1">
      <c r="A5" s="4" t="s">
        <v>51</v>
      </c>
      <c s="4" t="s">
        <v>52</v>
      </c>
      <c s="4" t="s">
        <v>53</v>
      </c>
      <c s="4" t="s">
        <v>54</v>
      </c>
      ...

Exceljs breaks with:

(node:3101) TypeError: Cannot read property 'match' of undefined
    at Object.decodeAddress (/Users/andreaslind/work/exceljs/lib/utils/col-cache.js:93:21)
    at value.cells.forEach.cellModel (/Users/andreaslind/work/exceljs/lib/doc/row.js:325:46)
    at Array.forEach (<anonymous>)
    at module.exports.set model [as model] (/Users/andreaslind/work/exceljs/lib/doc/row.js:319:17)
    at model.rows.forEach.rowModel (/Users/andreaslind/work/exceljs/lib/doc/worksheet.js:595:17)
    at Array.forEach (<anonymous>)
    at module.exports._parseRows (/Users/andreaslind/work/exceljs/lib/doc/worksheet.js:592:16)
    at module.exports.set model [as model] (/Users/andreaslind/work/exceljs/lib/doc/worksheet.js:606:10)
    at value.worksheets.forEach.worksheetModel (/Users/andreaslind/work/exceljs/lib/doc/workbook.js:197:23)
    at Array.forEach (<anonymous>)

(The line numbers might be off, as I'm currently running an older version, unfortunately)

I'm not sure the enclosed solution is per spec. Maybe someone else knows more?

And yes, it's actually the same spreadsheet that caused #536 -- I'll follow up if I'm able to find out how it was generated.

@papandreou
Copy link
Contributor Author

I just learned that the Excel file in question is an export from Xero, which is a piece of accounting software.

@guyonroche guyonroche merged commit ea6aaa1 into exceljs:master Apr 13, 2018
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.

None yet

2 participants