[]
Iterable<IPivotItem>IPivotItem 对象的集合。集合中的每一项对应字段类别中的单个数据条目。使用此接口可以访问由 IPivotField.getPivotItems() 返回的数据透视项,然后按索引或名称检索特定项。
Object[][] sourceData = {
{"Region", "Amount"},
{"North", 100},
{"South", 200},
{"East", 150}
};
worksheet.getRange("A1:B4").setValue(sourceData);
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "salesPivot");
IPivotField field = pivotTable.getPivotFields().get("Region");
field.setOrientation(PivotFieldOrientation.RowField);
IPivotItems items = field.getPivotItems();
items.get("North").setVisible(false);
get(int index) IPivotItem。IPivotItem。intgetCount()IPivotItem 对象的数量。forEach, iterator, spliteratorIPivotItem 对象的数量。当此集合由 IPivotField.getPivotItems() 返回时,计数包括该 PivotTable 字段中的项。
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Region", "Amount"},
{"East", 100},
{"West", 200},
{"East", 150}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
IPivotField field = pivotTable.getPivotFields().get("Region");
field.setOrientation(PivotFieldOrientation.RowField);
int count = field.getPivotItems().getCount();
IPivotItem 对象的数量。IPivotItem。使用此方法可获取与数据透视字段关联的 IPivotItems 集合中的数据透视项。
Object[][] sourceData = {
{"Category", "Product", "Amount"},
{"Beverages", "Tea", 10},
{"Beverages", "Coffee", 20},
{"Snacks", "Cookie", 15}
};
worksheet.getRange("A1:C4").setValue(sourceData);
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");
field.setOrientation(PivotFieldOrientation.RowField);
IPivotItem item = field.getPivotItems().get(0);
String name = item.getName();
index - 要返回的数据透视项的索引号。IPivotItem。IPivotItem。使用此方法可获取与数据透视字段关联的 IPivotItems 集合中的数据透视项。
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Banana", 80},
{"Apple", 120}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
IPivotField field = pivotTable.getPivotFields().get("Product");
field.setOrientation(PivotFieldOrientation.RowField);
IPivotItem item = field.getPivotItems().get("Apple");
name - 要返回的数据透视项的名称。IPivotItem。