Error when opening xlsx workbook containing a Pivot

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
GenasysCarl
Posts: 11
Joined: Mon Jan 09, 2017 6:15 am

Error when opening xlsx workbook containing a Pivot

Post by GenasysCarl »

Hi

After populating and saving a xlsx workbook, containing a Pivot, we get the below error when opening the saved file in excel.

Removed Part: /xl/pivotTables/pivotTable1.xml part with XML error. (PivotTable view) No attribute name may appear more than once in the same start tag or empty element tag. Line 12, column 215.

After then viewing the XML files, I found that the <pivotTableDefinition> tag in the xl\pivotTables\pivotTable1.xml file contains the "count" attributes twice.

I fixed this by preventing the "count" attribute to be added twice in the xpgPXML.pas => TXpgWriteXML.AddAttribute method

Code: Select all

procedure TXpgWriteXML.AddAttribute(const AName, AValue: AxUCString);
var
  sAtt : string;
begin
  sAtt:= FAttributes.pStart;
  if (sAtt.Contains('count=') and (AName = 'count')) then
    Exit;
//.
//.
//.
Not the best solution but it works for now. It is relatively safe (being case sensitive) as the only other attributes I could see which ends with "count" are part of another word e.g. "rowPageCount"
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Error when opening xlsx workbook containing a Pivot

Post by larsa »

Hello

This is probably a symptom of some other error. Can you please send me an Excel file that causes this error?
Lars Arvidsson, Axolot Data
Post Reply