[]
在数据量巨大的情况下,通过在数据透视表的不同区域添加或移动字段来更新其布局时,数据透视表的性能可能会受到影响。
GcExcel提供了,setdeferlayouupdate方法,通过延迟布局更新来提高数据透视表的性能。当设置为true时,pivot表只有在所有字段被添加或移动后才重新计算,而不是在每次更改后重新计算。您可以选择在进行所有更改后通过调用update方法更新透视表输出。
请参阅下面的示例代码来推迟布局更新。
// Defer layout update
pivottable.setDeferLayoutUpdate(true);
// Config pivot table's fields
IPivotField field_Category = pivottable.getPivotFields().get("Category");
field_Category.setOrientation(PivotFieldOrientation.RowField);
IPivotField field_Product = pivottable.getPivotFields().get("Product");
field_Product.setOrientation(PivotFieldOrientation.ColumnField);
IPivotField field_Amount = pivottable.getPivotFields().get("Amount");
field_Amount.setOrientation(PivotFieldOrientation.DataField);
// Update the pivottable.
pivottable.update();