Aspose.Cells.CellsException: This pivot field has more unique items than can be used in a pivot table

Hello,

I have an existing process that is building a pivot table tab. All of a sudden, it is reporting the following error:

Aspose.Cells.CellsException: This pivot field has more unique items than can be used in a pivot table. at Aspose.Cells.Pivot.PivotFieldCollection.(PivotField , Int32 ) at Aspose.Cells.Pivot.PivotFieldCollection.Add(PivotField pivotField) at Aspose.Cells.Pivot.PivotTable.AddFieldToArea(PivotFieldType fieldType, PivotField pivotField) at Aspose.Cells.Pivot.PivotTable.AddFieldToArea(PivotFieldType fieldType, String fieldName)

The line generating the exception is this:

pivotTable.AddFieldToArea(PivotFieldType.Row, “PolicyNumber”);

The number of rows on the data detail tab is 32,907 but I have other Excel files being generated from the exact same code that have more rows than that where the exception is not being thrown.

I am using the latest CELLSNET version 25.4.0

Do you have any suggestions for what I can look at to resolve this?

Thank you!

@eforden,

Since the release of Aspose.Cells v24.10, we included an enhancement regarding pivot table feature to cope with similar issue. Please note, we have added (overloaded) method: public int Add(string sourceData, string cell, string tableName, bool useSameSource, bool isXlsClassic) of PivotTableCollection that you may use in code (while adding the pivot table) with the new release to sort out your issue. Please see the concerned thread for your reference.

In case, you still find the issue, kindly provide a sample (console) application/program (complete source code without compilation errors) along with a sample Excel files (if any) to reproduce the issue on our end? We will check your issue soon.

PS. Please zip the resource files before attaching them.

Perfect, setting isXlsClassic to false resolved my issue. Thank you very much!!

@eforden
Thank you for your feedback. You are welcome. I’m glad you solved the issue by using the suggested overload method : public int Add(string sourceData, string cell, string tableName, bool useSameSource, bool isXlsClassic) of PivotTableCollection. If you have any questions, please feel free to contact us at any time.