Corruption when adding fields to Pivot Table

After generating data for a report, I am trying to dynamically add data fields from my data table to the pivot table. I believe the problem probably stems from changing the header columns on-the-fly.


Attached is a small excel template, and I’ve provided some sample code here.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please download and try the latest version:
Aspose.Cells
for .NET v7.1.2.3

and let us know your feedback.

You can use this sample code:


pivotTable.ColumnFields.Add(pivotTable.DataField);//move datafied to columns



OR

PivotField data = pivotTable.DataField;
pivotTable.AddFieldToArea(PivotFieldType.Column, data);

I just tried the new dll with the code and excel file I attached to this post. I am still getting a file corruption upon opening the generated .xlsx.


The code snippet you suggested is already in my code:

pt.ColumnFields.Add(pt.DataField);

Hi,

Thanks for your feedback and using the latest version.

I have added this issue in our database. Development team will look into this issue and once we will have some fix or update available, we will let you know asap.

This issue has been logged as CELLSNET-40513.

Hi,


Please try the latest fix v7.1.2.4. We have fixed your issue now.

Thank you

Thank you, I am no longer getting a corrupted file. However, the pivot table does not seem to refresh regardless of what I do in the code. I am able to get the correct functionality by setting the RefreshDataOnOpeningFile property. However, this causes the file to recompute when opened in Excel, and therefore requires a re-save.

Hi,

Please call pt.RefreshData() and pt.CalculateData() just before saving the workbook and let us know if it resolves your problem.

C#


pt.RefreshData()

pt.CalculateData();

m_currentWorkbook.Save(@“C:<span class=“kwrd”>out.xlsx”);

I tried the method calls you suggested, but it is not working perfectly. Now instead of the sum rows “Sum of 2009”, “Sum of 2010”, “Sum of 2011”,… I am getting duplicate rows with the same headers and data. Manually refreshing inside Excel re-corrects the pivot table. However, if I click on a header before refreshing, Excel will crash.

Hi,


Yes, you are right as I have tested/checked, we can notice the issue as you pointed out. We will look into it soon.

Tank you.

Hi,.

We have fixed this issue. Please download: Aspose.Cells for .NET v7.1.2.5

The issues you have found earlier (filed as CELLSNET-40513;CELLSNET-40513) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.