[]
Iterable<IPivotField>IPivotField 对象集合。IPivotFields 集合包含属于数据透视表报表的所有字段,包括当前在布局中不可见的字段。使用此接口可以枚举字段,或按索引或名称检索字段。
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Product", "Region", "Amount"},
{"Apple", "East", 100},
{"Pear", "West", 200},
{"Apple", "West", 150}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
IPivotFields pivotFields = pivotTable.getPivotFields();
IPivotField amountField = pivotFields.get("Amount");
get(int index) IPivotField。intgetCount()forEach, iterator, spliterator此方法返回 PivotTable 字段集合中可用的 IPivotField 对象总数。
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Region", "Product", "Amount"},
{"East", "Apple", 120},
{"West", "Orange", 80},
{"East", "Orange", 90}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
int count = pivotTable.getPivotFields().getCount();
使用此方法可按位置从 IPivotFields 集合中检索单个 IPivotField。
worksheet.getRange("A1:B5").setValue(new Object[][] {
{"Category", "Amount"},
{"Fruit", 120},
{"Fruit", 80},
{"Vegetables", 95},
{"Vegetables", 60}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B5"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
IPivotField field = pivotTable.getPivotFields().get(0);
field.setOrientation(PivotFieldOrientation.RowField);
index - 要从集合中检索的数据透视字段 的索引。IPivotField。IndexOutOfBoundsException - 如果 index 超出集合的有效范围。IPivotField。使用此方法可通过当前 IPivotFields 集合中的显示名称检索 PivotTable 字段。
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Region", "Product", "Amount"},
{"East", "Apple", 120},
{"West", "Apple", 80},
{"East", "Orange", 90}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
IPivotField field = pivotTable.getPivotFields().get("Product");
name - 要检索的 PivotTable 字段名称。此值必须与集合中的字段名称匹配。IPivotField。IllegalArgumentException - 如果集合中不存在具有指定名称的字段。