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

Fix misinterpreted ranges from <definedName> #636

Merged
merged 3 commits into from
Feb 7, 2019

Conversation

papandreou
Copy link
Contributor

Hi!

I ran into a file that contained a bunch of formulas and external references in <definedName>s, which caused this crash:

     Error: Out of bounds. Invalid column letter: OFFSET
      at Object.l2n (lib/utils/col-cache.js:60:13)
      at Object.decodeAddress (lib/utils/col-cache.js:97:24)
      at Object.decodeEx (lib/utils/col-cache.js:189:24)
      at CellMatrix.addCell (lib/utils/cell-matrix.js:19:29)
      at lib/doc/defined-names.js:159:18
      at Array.forEach (<anonymous>)
      at lib/doc/defined-names.js:157:26
      at Array.forEach (<anonymous>)
      at module.exports.set model [as model] (lib/doc/defined-names.js:155:11)
      at module.exports.set model [as model] (lib/doc/workbook.js:206:30)
      at lib/xlsx/xlsx.js:348:31

Turns out it's caused by what looks like a rather naive range extraction algorithm that doesn't take into account that the defined names could contain double quoted strings or formulas.

I'm unable to share the original file in its full glory, but I made a new one that reproduces one variant of the error.

I'm really not sure that this is the right fix -- it would probably be better to implement proper tokenization/parsing in extractRanges so that the full syntax is understood. Then again, that would be a lot of work, and to be honest I'm have no idea if those ranges are even used for anything important during the parsing?

@papandreou
Copy link
Contributor Author

@guyonroche, is anything holding this back? It happened to us again today, and we'd rather not go back to forking exceljs :)

@papandreou
Copy link
Contributor Author

@guyonroche, sorry to be a ping-in-the-ass 😼, but have you had a chance to take a look at this?

Copy link
Member

@Siemienik Siemienik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust that tests are green ;)

Copy link
Member

@alubbe alubbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

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.

4 participants