Thanks, I’ll try it, but I don’t see how it’s going to know what to order by with that code.
I added that line of code:
I did not do it in Excel manually, nor do I know how that would be done; as I stated in the original question, it is accomplished in Excel Interop as follows, but I don’t know what the equivalent in Aspose.Cells would be:
int sheetIndex = wb.Worksheets.Add();
PivotTableCollection pts = wb.Worksheets[sheetIndex].PivotTables;
int ptIndex = pts.Add("=PivotData!$A$1:$J$415", “A5”, “testPt”);
PivotTable pt = pts[ptIndex];
pt.DataFields.DisplayName = “Total Packages”;
pt.DataFields.DisplayName = “Total Purchases”;
pt.AddCalculatedField(“Average Price”, “=TotalPrice/TotalQty”, true);
pt.AddCalculatedField(“PercentOfTotal”, “=TotalPrice”, true);
pt.DataFields.DisplayName = “Percentage of Total”;
pt.RowFields.ShowInOutlineForm = true;
pt.RowFields.ShowCompact = true;
PivotField field = pt.RowFields;
field.IsAutoSort = true;
field.IsAscendSort = false;
field.AutoSortField = 1; // 0 based indexed position in the PivotTable.DataFields
pt.RefreshDataFlag = true;
pt.RefreshDataFlag = false;
wb.Save(dir + “output.xlsx”);
Thank you for writing back.
Please note, I have been using latest version of Aspose.Cells for .NET 16.11.3 (attached) therefore please give it a try on your side as well. In case the problem persists, please provide an executable sample console application along with its all dependencies (assemblies, input spreadsheets etc.). Please note, I have tried the code on your both shared samples and I am not able to observe the said problem.
Okay; I’m using 126.96.36.199; maybe something changed between my version and yours…
I am using the latest version available via the NuGet Package Manager in Visual Studio.
Let me provide you some more information about how we publish releases of Aspose.Cells APIs. Please note, we publish the major releases once every month during the 2nd week. These major releases are available through NuGet as well as Aspose download section. On top of it, we publish 1 minor release once every week whereas the download link/release archive is shared in the forums on concerned threads only. Such minor releases can be used in production environment without any problems because they contain all the fixes and enhancements from their predecessors.
That said, as you have acquired the release from the NuGet, it should be 16.11.0. You can keep using this release in case you are not facing any problem. In case of any issue, we suggest you to use the most recent revision of the API. If you are not certain which revision is most recent, you can always post your concerns in support forums, we will test the case against the most recent release and share it with you in case the problem has already been resolved. If the problem persists, we will log it in our bug tracking system and share a tracking code for future reference as well as automated notifications regarding the particular problem.
Thanks; this particular issue has been solved (by you, I think), so versioning is not an issue with me at present. Thanks for the info!