We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pivot Grid is not saving with column fields

Hello,

I'm caught in a weird issue were in the changes are not saving and getting "Index out of bound exception" while saving. It was working properly with 4.9. and it breaks with the latest version downloaded today.

Code below:

for (int pivotFieldIndex = 0; pivotFieldIndex < pivotFields.Count; pivotFieldIndex++)

{

if (pivotFields[pivotFieldIndex].Name.Equals("Desk") ||

pivotFields[pivotFieldIndex].Name.Equals("Trader") ||

pivotFields[pivotFieldIndex].Name.Equals("Report Date"))

{

pivotTable1.PageFields.Add(pivotFields[pivotFieldIndex]);

continue;

}

if (pivotFields[pivotFieldIndex].Name.Equals("Issuer(P)"))

{

pivotTable1.RowFields.Add(pivotFields[pivotFieldIndex]);

continue;

}

if (pivotFields[pivotFieldIndex].Name.Equals("Period"))

{

pivotTable1.ColumnFields.Add(pivotFields[pivotFieldIndex]);

continue;

}

if (pivotFields[pivotFieldIndex].Name.Equals("Total PnL") ||

pivotFields[pivotFieldIndex].Name.Equals("New/Cancel'd") ||

pivotFields[pivotFieldIndex].Name.Equals("Credit") ||

pivotFields[pivotFieldIndex].Name.Equals("Rates") ||

pivotFields[pivotFieldIndex].Name.Equals("Total Less Rates") ||

pivotFields[pivotFieldIndex].Name.Equals("Credit Notional") ||

pivotFields[pivotFieldIndex].Name.Equals("CS01") ||

pivotFields[pivotFieldIndex].Name.Equals("IR01") ||

pivotFields[pivotFieldIndex].Name.Equals("Trading less FX"))

{

pivotFields[pivotFieldIndex].DisplayName = pivotFields[pivotFieldIndex].Name;

pivotTable1.DataFields.Add

(pivotFields[pivotFieldIndex]);

pivotFields[pivotFieldIndex].NumberFormat = "#,##0;[Red](#,##0)";

pivotFields[pivotFieldIndex].Number = 4;

continue;

}

if (pivotFields[pivotFieldIndex].Name.Equals("Total Less Rates Less FX"))

{

if (reportType.Equals("1"))

{

pivotTable1.DataFields.Add

(pivotFields[pivotFieldIndex]);

pivotFields[pivotFieldIndex].NumberFormat = "#,##0;[Red](#,##0)";

continue;

}

}

if (pivotFields[pivotFieldIndex].Name.Equals("Trading"))

{

if (reportType.Equals("2"))

{

pivotTable1.DataFields.Add

(pivotFields[pivotFieldIndex]);

pivotFields[pivotFieldIndex].NumberFormat = "#,##0;[Red](#,##0)";

pivotFields[pivotFieldIndex].Number = 5;

continue;

}

}

if (pivotFields[pivotFieldIndex].Name.Equals("Trading Less FX"))

{

if (!reportType.Equals("2") || !reportType.Equals("1"))

{

pivotTable1.DataFields.Add

(pivotFields[pivotFieldIndex]);

pivotFields[pivotFieldIndex].NumberFormat = "#,##0;[Red](#,##0)";

continue;

}

}

}

If you comment the bold line, it saves properly. Please help!

Thanks,

Pradeep

Hi Pradeep,

Thanks for sharing code with us. Please send us the Excel template file which you are using. This will help us to drill down the issue.

Thanks,

Unfortunately I cannot share you the data inside the template, but attaching a screenshot for the template. Hope this helps!

Source Data Columns

Rank Issuer (P) Total PnL New/Cancel'd Credit Rates Total Less Rates Trading Credit Notional CS01 IR01

Target is as attached.

Regards,

Pradeep

Try this scenario

1) Add couple of page fields

2) Add a column field

3) Add couple of data fields

4) Add 3) as a column field and save the workbook

It will throw the error!

Regards,

Pradeep

We did couple of POC using the trial version and right now got the latest version (Licensed) for migrating our reports using ASPOSE.Cells. It breaks the entire POC we made before since you guys dont offer backward compatibility and we are not sure whether we can use this unstable version for our release (It doesn't even save a pivot table properly).

PLEASE HELP!

Any luck with this request?

Its interesting …good source of knowledge…
================

Savings Rates

John Watson - What do you mean?

Aspose team, if we have items inside the column field, the pivot sheet is not getting saved.

For the period column above in the example, it has few items inside and I believe this is causing the issue.

Regards,

Pradeep

Hi,

We will fix this issue in about two days time (hopefully). But, if you could send your template file, it will very kind of you and can help in figuring the issue more accurately.

Thank you.<span style=“font-size: 10pt; font-family: “Microsoft YaHei”,“serif”;”>

Hi Pardeep,

Please try the updated version Aspose.Cells5.1.3.6.zip attached. Furthermore, we will still working to resolve this issue.