Sheetjs: Formatting is not getting read properly

Created on 19 Aug 2016  路  1Comment  路  Source: SheetJS/sheetjs

We are seeing an issue in reading xlsx files.
If a cell contains all the text as formatted in bold / italics then the formatting is not getting read. The text is treated as normally.
But if some part of the text is formatted then it is getting read properly.

https://github.com/SheetJS/js-xlsx/files/427040/rich_text_stress.xlsx

Following is the output of the above xlsx file:

!ref "A1:B15"
A1 {
  "t": "s",
  "v": "normal",
  "r": "<t>normal</t>",
  "h": "normal",
  "w": "normal"
}
B1 {
  "t": "s",
  "v": "this text is normal, sure enough",
  "r": "<t>this text is normal, sure enough</t>",
  "h": "this text is normal, sure enough",
  "w": "this text is normal, sure enough"
}
A2 {
  "t": "s",
  "v": "bold",
  "r": "<t>bold</t>",
  "h": "bold",
  "w": "bold"
}
B2 {
  "t": "s",
  "v": "this text is bold, sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><b/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t>bold</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t>, sure enough</t></r>",
  "h": "this text is <span style=\"font-weight: bold;\">bold</span><span style=\"\">, sure enough</span>",
  "w": "this text is bold, sure enough"
}
A3 {
  "t": "s",
  "v": "italic",
  "r": "<t>italic</t>",
  "h": "italic",
  "w": "italic"
}
B3 {
  "t": "s",
  "v": "this text is italicized sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><i/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>italicized</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"font-style: italic;\">italicized</span><span style=\"\"> sure enough</span>",
  "w": "this text is italicized sure enough"
}
A4 {
  "t": "s",
  "v": "underline",
  "r": "<t>underline</t>",
  "h": "underline",
  "w": "underline"
}
B4 {
  "t": "s",
  "v": "this text is underlined, sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><u/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>underlined</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t>, sure enough</t></r>",
  "h": "this text is <span style=\"\">underlined</span><span style=\"\">, sure enough</span>",
  "w": "this text is underlined, sure enough"
}
A5 {
  "t": "s",
  "v": "sz10",
  "r": "<t>sz10</t>",
  "h": "sz10",
  "w": "sz10"
}
B5 {
  "t": "s",
  "v": "this text is sz10, sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><sz val=\"10\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>sz10,</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"\">sz10,</span><span style=\"\"> sure enough</span>",
  "w": "this text is sz10, sure enough"
}
A6 {
  "t": "s",
  "v": "strike",
  "r": "<t>strike</t>",
  "h": "strike",
  "w": "strike"
}
B6 {
  "t": "s",
  "v": "this text is stricken sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><strike/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>stricken</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"\">stricken</span><span style=\"\"> sure enough</span>",
  "w": "this text is stricken sure enough"
}
A7 {
  "t": "s",
  "v": "subscript",
  "r": "<t>subscript</t>",
  "h": "subscript",
  "w": "subscript"
}
B7 {
  "t": "s",
  "v": "this text is subscripted sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><vertAlign val=\"subscript\"/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>subscripted</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"\">subscripted</span><span style=\"\"> sure enough</span>",
  "w": "this text is subscripted sure enough"
}
A8 {
  "t": "s",
  "v": "superscript",
  "r": "<t>superscript</t>",
  "h": "superscript",
  "w": "superscript"
}
B8 {
  "t": "s",
  "v": "this text is superscripted sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><vertAlign val=\"superscript\"/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>superscripted</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"\">superscripted</span><span style=\"\"> sure enough</span>",
  "w": "this text is superscripted sure enough"
}
A9 {
  "t": "s",
  "v": "outline",
  "r": "<t>outline</t>",
  "h": "outline",
  "w": "outline"
}
B9 {
  "t": "s",
  "v": "this text is outlined sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><outline/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>outlined</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"\">outlined</span><span style=\"\"> sure enough</span>",
  "w": "this text is outlined sure enough"
}
A10 {
  "t": "s",
  "v": "shadow",
  "r": "<t>shadow</t>",
  "h": "shadow",
  "w": "shadow"
}
B10 {
  "t": "s",
  "v": "this text is shadowed sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><shadow/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>shadowed</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"\">shadowed</span><span style=\"\"> sure enough</span>",
  "w": "this text is shadowed sure enough"
}
A11 {
  "t": "s",
  "v": "2underline",
  "r": "<t>2underline</t>",
  "h": "2underline",
  "w": "2underline"
}
B11 {
  "t": "s",
  "v": "this text is double underlined sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><u val=\"double\"/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>double</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> underlined sure enough</t></r>",
  "h": "this text is <span style=\"\">double</span><span style=\"\"> underlined sure enough</span>",
  "w": "this text is double underlined sure enough"
}
A12 {
  "t": "s",
  "v": "accounting",
  "r": "<t>accounting</t>",
  "h": "accounting",
  "w": "accounting"
}
B12 {
  "t": "s",
  "v": "this text is accounting underlined sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><u val=\"singleAccounting\"/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>accounting underlined</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"\">accounting underlined</span><span style=\"\"> sure enough</span>",
  "w": "this text is accounting underlined sure enough"
}
A13 {
  "t": "s",
  "v": "2accounting",
  "r": "<t>2accounting</t>",
  "h": "2accounting",
  "w": "2accounting"
}
B13 {
  "t": "s",
  "v": "this text is double accounting underlined sure enough",
  "r": "<r><t xml:space=\"preserve\">this text is </t></r><r><rPr><u val=\"doubleAccounting\"/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>double accounting underlined</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> sure enough</t></r>",
  "h": "this text is <span style=\"\">double accounting underlined</span><span style=\"\"> sure enough</span>",
  "w": "this text is double accounting underlined sure enough"
}
A15 {
  "t": "s",
  "v": "BIU",
  "r": "<t>BIU</t>",
  "h": "BIU",
  "w": "BIU"
}
B15 {
  "t": "s",
  "v": "lets try all combinations of BIU in cell",
  "r": "<r><t xml:space=\"preserve\">lets </t></r><r><rPr><i/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>try</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> </t></r><r><rPr><u/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\">all </t></r><r><rPr><i/><u/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>combinations</t></r><r><rPr><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> </t></r><r><rPr><b/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\">of </t></r><r><rPr><b/><i/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>BIU</t></r><r><rPr><b/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\"> </t></r><r><rPr><b/><u/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t xml:space=\"preserve\">in </t></r><r><rPr><b/><i/><u/><sz val=\"12\"/><color theme=\"1\"/><rFont val=\"Calibri\"/><scheme val=\"minor\"/></rPr><t>cell</t></r>",
  "h": "lets <span style=\"font-style: italic;\">try</span><span style=\"\"> </span><span style=\"\">all </span><span style=\"font-style: italic;\">combinations</span><span style=\"\"> </span><span style=\"font-weight: bold;\">of </span><span style=\"font-weight: bold;font-style: italic;\">BIU</span><span style=\"font-weight: bold;\"> </span><span style=\"font-weight: bold;\">in </span><span style=\"font-weight: bold;font-style: italic;\">cell</span>",
  "w": "lets try all combinations of BIU in cell"
}
[rich_text_stress.xlsx](https://github.com/SheetJS/js-xlsx/files/427040/rich_text_stress.xlsx)

Style

>All comments

Just a note on the feature: rich text is handled separately from cell styles.

We offer this in the Pro compendium. Since companies have paid for the features already, it would be unfair to them if we turned around and made it available as open source. We have a longer comment in a gist.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alex0007 picture Alex0007  路  3Comments

lxzhh picture lxzhh  路  3Comments

gustavosimil picture gustavosimil  路  3Comments

sangpuion picture sangpuion  路  3Comments

goxr3plus picture goxr3plus  路  3Comments