Hello!
I've encountered problems when reading file using EPP saving it and trying to read again.
Steps to reproduce
Read example file with EPP
Save file
Try read saved file
Sample code
using OfficeOpenXml;
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
Console.WriteLine("Reading example.xlsx");
using var package = new ExcelPackage();
await package.LoadAsync(new FileInfo("example.xlsx"));
Console.WriteLine("Worksheets count: " + package.Workbook.Worksheets.Count);
await package.SaveAsAsync("example_saved.xlsx");
Console.WriteLine("Saved as example_saved.xlsx");
Console.WriteLine("=======");
Console.WriteLine("Try read example_saved.xlsx");
using var anotherPackage = new ExcelPackage();
await anotherPackage.LoadAsync(new FileInfo("example_saved.xlsx"));
Console.WriteLine("Worksheets count: " + anotherPackage.Workbook.Worksheets.Count);
Got exception
Unhandled exception. System.Xml.XmlException: Name cannot begin with the '"' character, hexadecimal value 0x22. Line 1, position 236.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at OfficeOpenXml.Style.ExcelRichText.ReadrPr(XmlReader xr)
at OfficeOpenXml.Style.ExcelRichText..ctor(XmlReader xr, ExcelRichTextCollection collection)
at OfficeOpenXml.Style.ExcelRichTextCollection..ctor(XmlReader xr, ExcelWorkbook wb)
at OfficeOpenXml.ExcelWorkbook.GetSharedStrings()
at OfficeOpenXml.ExcelWorkbook..ctor(ExcelPackage package, XmlNamespaceManager namespaceManager)
at OfficeOpenXml.ExcelPackage.get_Workbook()
at Program.<Main>$(String[] args) in /Users/artem/dev/EppBug/EppBug/Program.cs:line 17
at Program.<Main>(String[] args)
EPPlus usage
Personal use
Environment
MacOs
Epplus version
7.5.0
Spreadsheet application
Excel
Description
Hello! I've encountered problems when reading file using EPP saving it and trying to read again.
Steps to reproduce
Sample code
Got exception
Example files:
Sample project:
I suppose this bug is connected to insufficient escape values for rich text. Take a look at
xl/sharedStrings.xml
:This is bad formatted XML. Root cause is font name:
ALS Hauss"
. Excel saves it asALS Hauss"e;