This pivot field has more unique items than can be used in a pivot table

Aspose.Cells for .NET在使用Aspose.Cells.Pivot.PivotTable 的AddFieldToArea(PivotFieldType fieldType, string fieldName)時,新增PivotFieldType.Row的資料進去,會出現"This pivot field has more unique items than can be used in a pivot table."的例外錯誤。

目前確認只要唯一值的數量超出32,767時就會跳出例外錯誤,並且更新至目前最新版24.9也依然沒有解決問題,由於使用純數字欄位測試也能出現相同的狀況,推測應該不是資料內存或是資料長度的問題。

官方目前的限制應該為1,048,576,但實際使用卻有32,767限制。

官方文件與連結

@ScarSu,

Could you please provide a sample (console) application/program (complete source code without compilation errors) along with a sample Excel file (if any) to reproduce the issue on our end? We will check your issue soon.

Please zip the resource files before attaching them.

@ScarSu
By creating a sample file and testing it on the latest version v24.9 using the following sample code, we can reproduce the issue. Discovered CellsException: This pivot field has more unique items than can be used in a pivot table. Excel can add pivot tables normally, please refer to the attachment. result.png (48.7 KB)

// Load the workbook
Workbook workbook = new Workbook(filePath + "sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

// Add a Pivot Table
int pivotTableIndex = worksheet.PivotTables.Add("=A1:C133823", "J1", "PivotTable1");
PivotTable pivotTable = worksheet.PivotTables[pivotTableIndex];

// Set the row fields
pivotTable.AddFieldToArea(PivotFieldType.Row, 0); 
pivotTable.AddFieldToArea(PivotFieldType.Row, 1); 

// Set the data field
pivotTable.AddFieldToArea(PivotFieldType.Data, 2);

// Save the workbook with the Pivot Table
workbook.Save(filePath + "out_net.xlsx");

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-56899

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks for your quickly response.

@ScarSu
You are welcome. We will notify you promptly once there are any updates.

@ScarSu,

We are pleased to inform you that your issue (Ticket ID: “CELLSNET-56899”) has been resolved. The fix/enhancement will be included in our upcoming release (Aspose.Cells v24.10) that we plan to release in this week. You will be notified when the next version is released.

Please note, we have added method: public int Add(string sourceData, string cell, string tableName, bool useSameSource, bool isXlsClassic) of PivotTableCollection that you may use with the new release to sort out your issue.

1 Like

The issues you have found earlier (filed as CELLSNET-56899) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi