When multiple textruns exist in a single cell, the loop in LoadCells() is broken, causing the rest of the <sheetData> to not be read. The applicable code is in ExcelWorksheet.cs, line 1280:
```
else if (xr.LocalName == "is") //Inline string
{
xr.Read();
if (xr.LocalName == "t")
{
_values.SetValue(address._fromRow, address._fromCol, ConvertUtil.ExcelDecodeString(xr.ReadElementContentAsString()));
//cell._value = xr.ReadInnerXml();
}
else
{
_values.SetValue(address._fromRow, address._fromCol, xr.ReadOuterXml()); // <-- this line
_types.SetValue(address._fromRow, address._fromCol, "rt");
_flags.SetFlagValue(address._fromRow, address._fromCol, true, CellFlags.RichText);
//cell.IsRichText = true;
}
}
else
{
break;
}
```
Example XML:
```
<is>
<r>
<rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><sz val="9.99937011841774"></sz><color theme="1"></color><rFont val="Calibri"></rFont></rPr>
<t xml:space="preserve"> </t>
</r>
<r>
<rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><u val="none"></u><sz val="8"></sz><color rgb="FF000000"></color><rFont val="Arial"></rFont></rPr>
<t xml:space="preserve">Shifra Gitelman; Meital Sari Azrieli; Moses Azriel; Asaf Azriel </t>
</r>
<r>
<rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><sz val="9.99937011841774"></sz><color theme="1"></color><rFont val="Calibri"></rFont></rPr>
<t xml:space="preserve"> </t>
</r>
</is>
```
The code will read the first <r> element using xr.ReadOuterXml(), leaving the next textrun in queue. This causes the next iteration of the loop to break at line 1287.
Comments: I attempted to fix the issue by adding the following at line 1278 in Worksheet.cs: ``` else if (xr.LocalName == "r") { StringBuilder sb = new StringBuilder(); while (xr.LocalName == "r") { sb.Append(xr.ReadOuterXml()); } _values.SetValue(address._fromRow, address._fromCol, sb.ToString()); _types.SetValue(address._fromRow, address._fromCol, "rt"); _flags.SetFlagValue(address._fromRow, address._fromCol, true, CellFlags.RichText); } ``` This adds all textruns to the valet of the cell, but results in a corrupted package, specifically within sharedStrings.xml: ``` <si> <r xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><sz val="9.99937011841774"></sz><color theme="1"></color><rFont val="Calibri"></rFont></rPr> <t xml:space="preserve"></t> </r> <r xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><u val="none"></u><sz val="8"></sz><color rgb="FF000000"></color><rFont val="Arial"></rFont></rPr> <t xml:space="preserve">Shifra Gitelman; Meital Sari Azrieli; Moses Azriel; Asaf Azriel </t> </r> <r xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><sz val="9.99937011841774"></sz><color theme="1"></color><rFont val="Calibri"></rFont></rPr> <t xml:space="preserve"></t> </r> </si> ``` Opening this file causes Excel to prompt to repair the spreadsheet.
```
else if (xr.LocalName == "is") //Inline string
{
xr.Read();
if (xr.LocalName == "t")
{
_values.SetValue(address._fromRow, address._fromCol, ConvertUtil.ExcelDecodeString(xr.ReadElementContentAsString()));
//cell._value = xr.ReadInnerXml();
}
else
{
_values.SetValue(address._fromRow, address._fromCol, xr.ReadOuterXml()); // <-- this line
_types.SetValue(address._fromRow, address._fromCol, "rt");
_flags.SetFlagValue(address._fromRow, address._fromCol, true, CellFlags.RichText);
//cell.IsRichText = true;
}
}
else
{
break;
}
```
Example XML:
```
<is>
<r>
<rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><sz val="9.99937011841774"></sz><color theme="1"></color><rFont val="Calibri"></rFont></rPr>
<t xml:space="preserve"> </t>
</r>
<r>
<rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><u val="none"></u><sz val="8"></sz><color rgb="FF000000"></color><rFont val="Arial"></rFont></rPr>
<t xml:space="preserve">Shifra Gitelman; Meital Sari Azrieli; Moses Azriel; Asaf Azriel </t>
</r>
<r>
<rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><sz val="9.99937011841774"></sz><color theme="1"></color><rFont val="Calibri"></rFont></rPr>
<t xml:space="preserve"> </t>
</r>
</is>
```
The code will read the first <r> element using xr.ReadOuterXml(), leaving the next textrun in queue. This causes the next iteration of the loop to break at line 1287.
Comments: I attempted to fix the issue by adding the following at line 1278 in Worksheet.cs: ``` else if (xr.LocalName == "r") { StringBuilder sb = new StringBuilder(); while (xr.LocalName == "r") { sb.Append(xr.ReadOuterXml()); } _values.SetValue(address._fromRow, address._fromCol, sb.ToString()); _types.SetValue(address._fromRow, address._fromCol, "rt"); _flags.SetFlagValue(address._fromRow, address._fromCol, true, CellFlags.RichText); } ``` This adds all textruns to the valet of the cell, but results in a corrupted package, specifically within sharedStrings.xml: ``` <si> <r xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><sz val="9.99937011841774"></sz><color theme="1"></color><rFont val="Calibri"></rFont></rPr> <t xml:space="preserve"></t> </r> <r xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><u val="none"></u><sz val="8"></sz><color rgb="FF000000"></color><rFont val="Arial"></rFont></rPr> <t xml:space="preserve">Shifra Gitelman; Meital Sari Azrieli; Moses Azriel; Asaf Azriel </t> </r> <r xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <rPr><b val="0"></b><i val="0"></i><strike val="0"></strike><sz val="9.99937011841774"></sz><color theme="1"></color><rFont val="Calibri"></rFont></rPr> <t xml:space="preserve"></t> </r> </si> ``` Opening this file causes Excel to prompt to repair the spreadsheet.