EPPlusSoftware / EPPlus

EPPlus-Excel spreadsheets for .NET
https://epplussoftware.com
Other
1.78k stars 273 forks source link

Exception while reading from Workbook #359

Closed rdhasse closed 3 years ago

rdhasse commented 3 years ago

Hello,

We recently observed the below exception while reading from an Excel workbook. If we simply open and save the file the exception goes away. Unfortunately, there is no point in sending the Excel file because after removing confidential data and saving the issue no longer occurs. Below is the error message and stacktrace. Please let us know if there's anything we can look for to explain this error. One theory is the workbook was created with an old, unsupported version of Excel.

The 'worksheet' start tag on line 2 position 2 does not match the end tag of 'formula'. Line 2, position 3958.

  at System.Xml.XmlTextReaderImpl.Throw(Exception e)

at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag) at System.Xml.XmlTextReaderImpl.ParseEndElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) at System.Xml.XmlDocument.Load(XmlReader reader) at OfficeOpenXml.XmlHelper.LoadXmlSafe(XmlDocument xmlDoc, String xml, Encoding encoding) at OfficeOpenXml.ExcelWorksheet.CreateXml() at OfficeOpenXml.ExcelWorksheet..ctor(XmlNamespaceManager ns, ExcelPackage excelPackage, String relID, Uri uriWorksheet, String sheetName, Int32 sheetID, Int32 positionID, Nullable`1 hide) at OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage pck, XmlNamespaceManager nsm, XmlNode topNode) at OfficeOpenXml.ExcelWorkbook.get_Worksheets()

JanKallman commented 3 years ago

Hello, It seems that something goes wrong when parsing the Xml for the worksheet. I will have a hard time finding the problem without the actual workbook.

rdhasse commented 3 years ago

I found a similar issue with another workbook which I have uploaded. Also, I pasted the error message and stacktrace below.

workbook_with_issue.zip

The 'br' start tag on line 18 position 33 does not match the end tag of 'b'. Line 19, position 9.

at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag) at System.Xml.XmlTextReaderImpl.ParseEndElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at OfficeOpenXml.XmlHelper.LoadXmlSafe(XmlDocument xmlDoc, Stream stream) at OfficeOpenXml.Drawing.Vml.ExcelVmlDrawingBaseCollection..ctor(ExcelWorksheet ws, Uri uri, String worksheetRelIdPath) at OfficeOpenXml.Drawing.Vml.ExcelVmlDrawingCollection..ctor(ExcelWorksheet ws, Uri uri) at OfficeOpenXml.ExcelWorksheet.CreateVmlCollection() at OfficeOpenXml.ExcelWorksheet.LoadComments() at OfficeOpenXml.ExcelWorksheet..ctor(XmlNamespaceManager ns, ExcelPackage excelPackage, String relID, Uri uriWorksheet, String sheetName, Int32 sheetID, Int32 positionID, Nullable`1 hide) at OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage pck, XmlNamespaceManager nsm, XmlNode topNode) at OfficeOpenXml.ExcelWorkbook.get_Worksheets() at OfficeOpenXml.ExcelWorkbook.GetDefinedNames() at OfficeOpenXml.ExcelPackage.get_Workbook()

JanKallman commented 3 years ago

Thanks, I'll have a look

JanKallman commented 3 years ago

This second issue should be fixed in 5.6.4. I'll close this issue as I can't replicate the first one. Feel free to reopen it if you can provide me with a reproducible test case.