Crash on Invalid Color Index #1412

Closed
opened 2019-01-23 22:14:05 +00:00 by AuHau · 2 comments
AuHau commented 2019-01-23 22:14:05 +00:00 (Migrated from github.com)

I believe a similar problem to https://github.com/ClosedXML/ClosedXML/issues/307 happens here. I have XLSX file that SheetJS is not able to parse (the file is can be downloaded here).

It fails with Uncaught Error: <color indexed="206"/>.

I believe a similar problem to https://github.com/ClosedXML/ClosedXML/issues/307 happens here. I have XLSX file that SheetJS is not able to parse (the file is can be downloaded [here](https://github.com/SheetJS/js-xlsx/files/2789370/ISRaD_Template_Info_faulty.xlsx)). It fails with `Uncaught Error: <color indexed="206"/>`.
SheetJSDev commented 2019-01-23 23:03:10 +00:00 (Migrated from github.com)

206 is not a valid indexed color according to MS-XLS 2.5.161:

The value MUST be one of the following values: a value greater than or equal to 0x000 and less than or equal to 0x0041, a value greater than or equal to 0x004D and less than or equal to 0x004F, 0x0051, or 0x7FFF.

Inspecting the sheet, that particular style is used in exactly one cell! It is referenced in font ID 20:

    <font>
      <sz val="12"/>
      <color indexed="206"/>
      <name val="Calibri"/>
      <family val="2"/>
      <charset val="204"/>
    </font>

Which is only referenced in style ID 56:

    <xf numFmtId="0" fontId="20" fillId="0" borderId="0" xfId="0" applyFont="1"/>

and that particular style is only used in the 9th sheet xml:

    <c r="B33" s="56"/>

What's interesting is that Excel refuses to show the "Format Cells" popup when you right click on the cell B33 in the "incubation" worksheet! So it seems that this in fact a broken file that excel just opens. If you type text, it shows up as red:

issue1412

Unfortunately VBA is of no help, manually setting the color index with something like Range("A1").Font.ColorIndex = 206 results in run-time error 9: "Subscript out of range".

Do you know how this file was generated? The file properties suggest Excel 2016 for Mac. Did it come from Excel? If so do you know what the build was? (it might have worked in a specific point release, and we can use that to figure out the original intention)

206 is not a valid indexed color according to [`MS-XLS 2.5.161`](https://msdn.microsoft.com/en-us/library/dd773056.aspx): > The value MUST be one of the following values: a value greater than or equal to 0x000 and less than or equal to 0x0041, a value greater than or equal to 0x004D and less than or equal to 0x004F, 0x0051, or 0x7FFF. Inspecting the sheet, that particular style is used in exactly one cell! It is referenced in font ID 20: ```xml <font> <sz val="12"/> <color indexed="206"/> <name val="Calibri"/> <family val="2"/> <charset val="204"/> </font> ``` Which is only referenced in style ID 56: ```xml <xf numFmtId="0" fontId="20" fillId="0" borderId="0" xfId="0" applyFont="1"/> ``` and that particular style is only used in the 9th sheet xml: ```xml <c r="B33" s="56"/> ``` What's interesting is that Excel refuses to show the "Format Cells" popup when you right click on the cell B33 in the "incubation" worksheet! So it seems that this in fact a broken file that excel just opens. If you type text, it shows up as red: ![issue1412](https://user-images.githubusercontent.com/6070939/51642201-6681fa00-1f36-11e9-8dd0-defcd9b5833b.png) Unfortunately VBA is of no help, manually setting the color index with something like `Range("A1").Font.ColorIndex = 206` results in run-time error 9: "Subscript out of range". Do you know how this file was generated? The file properties suggest Excel 2016 for Mac. Did it come from Excel? If so do you know what the build was? (it might have worked in a specific point release, and we can use that to figure out the original intention)
AuHau commented 2019-01-23 23:11:30 +00:00 (Migrated from github.com)

Thanks for fast and thorough analysis!

To be honest, I have no idea how this file was generated as I am just helping out a friend to build a viewer for their project. I will try to get the information you ask for.

I solved it by manually removing the color index from the styles of the file, so it is nothing urgent from my side, just wanted to let you know about the problem.

Thanks for fast and thorough analysis! To be honest, I have no idea how this file was generated as I am just helping out a friend to build a viewer for their project. I will try to get the information you ask for. I solved it by manually removing the color index from the styles of the file, so it is nothing urgent from my side, just wanted to let you know about the problem.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#1412
No description provided.