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

Protect cell fix #166

Merged
merged 1 commit into from
Sep 14, 2016
Merged

Protect cell fix #166

merged 1 commit into from
Sep 14, 2016

Conversation

jayflo
Copy link

@jayflo jayflo commented Aug 10, 2016

Integer cell values are interpreted as Dates based on cellXfs.xf elements in xl/styles.xml. However, when any spreadsheet has "protected" cells, these xf elements can have the form:

<xf borderId="1" fillId="10" fontId="3" numFmtId="0" xfId="0" applyProtection="1" applyAlignment="1" applyFill="1" applyBorder="1" applyFont="1">
  <alignment horizontal="center" vertical="center"/>
  <protection locked="0"/>
</xf>

Currently, unknown child elements of xf elements are not handled correctly and this causes xl/styles.xml to be parsed incorrectly (this is the root of the problem). When xl/styles.xml is parsed incorrectly, the lib/xlsx/style/styles-xform.js method getStyleModel can fail to find the numFmt for Date types. The change here does not have to be "the fix" (you/we can also add an xform for protected elements) but it does fix the problem since unknown child cells of xf elements will not cause the parent ListXform.parseClose to remove the parser.

Since exceljs may not be able to account for all possible element types in the xml files, it should at least ignore unknown elements and only process those that it knows how to "handle." This way exceljs will do its best to work correctly for the subset of features it supports.

Let me know if more info is needed.

@jayflo
Copy link
Author

jayflo commented Aug 10, 2016

You might also consider throwing an error when a cell needs to lookup a style for an index that does not exist. Since Excel is provides correct indices, the only reason the index would not exist during the parsing process would be because of a bug in exceljs. Then the bug could be found much more quickly and be dealt with.

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.

2 participants