This project has moved. For the latest updates, please go here.
1
Vote

Pivot Table : System.Xml.XmlException: An error occurred while parsing EntityName. Line 1, position 2102.

description

Hello, I encountered issue related with pivot, Please help me.
Thanks in advance any help
            var fileInfo = new FileInfo(path);
            using (var package = new ExcelPackage(fileInfo))
            {
                var pivotSheet = package.Workbook.Worksheets.Add("PivotTable");
                var sourceSheet = package.Workbook.Worksheets["Source Data"];

                var range = pivotSheet.Cells["A1"];
                var source = sourceSheet?.Cells[sourceSheet.Dimension.Address];
                var name = "PivotTable1";

                var pivotTable = pivotSheet.PivotTables.Add(range, source, name);          <== Error is here
System.Xml.XmlException: An error occurred while parsing EntityName. Line 1, position 2102.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
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.XmlHelper.LoadXmlSafe(XmlDocument xmlDoc, String xml, Encoding encoding)
at OfficeOpenXml.Table.PivotTable.ExcelPivotCacheDefinition..ctor(XmlNamespaceManager ns, ExcelPivotTable pivotTable, ExcelRangeBase sourceAddress, Int32 tblId)
at OfficeOpenXml.Table.PivotTable.ExcelPivotTable..ctor(ExcelWorksheet sheet, ExcelAddressBase address, ExcelRangeBase sourceAddress, String name, Int32 tblId)
at OfficeOpenXml.Table.PivotTable.ExcelPivotTableCollection.Add(ExcelAddressBase Range, ExcelRangeBase Source, String Name)

comments