[]
Iterable<IPivotFormula>IPivotFormulas 对象由 IPivotTable.getPivotFormulas() 返回,并提供对为 PivotTable 定义的公式的访问,例如由计算项创建的公式。
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Product", "Category", "Amount"},
{"Apple", "Fruit", 120},
{"Banana", "Fruit", 80},
{"Bran", "Snack", 60}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
pivotTable.getPivotFields().get("Product").getCalculatedItems().add("TotalFruit", "=Product[Apple] + Product[Banana]");
IPivotFormulas formulas = pivotTable.getPivotFormulas();
get(int index) IPivotFormula。intgetCount()forEach, iterator, spliterator此集合由 IPivotTable.getPivotFormulas() 返回,包含为 PivotTable 定义的公式,例如由计算项创建的公式。
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Product", "Category", "Amount"},
{"Apple", "Fruit", 120},
{"Banana", "Fruit", 80},
{"Bran", "Snack", 60}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
pivotTable.getPivotFields().get("Product").getCalculatedItems().add("TotalFruit", "=Product[Apple] + Product[Banana]");
int count = pivotTable.getPivotFormulas().getCount();
IPivotFormula。使用此方法可从 IPivotTable.getPivotFormulas() 集合中检索公式,例如由 PivotTable 中的计算项创建的公式。
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Product", "Category", "Amount"},
{"Apple", "Fruit", 120},
{"Banana", "Fruit", 80},
{"Bran", "Snack", 60}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:C4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("E1"), "SalesPivot");
pivotTable.getPivotFields().get("Product").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.ColumnField);
pivotTable.getPivotFields().get("Product").getCalculatedItems().add("TotalFruit", "=Product[Apple] + Product[Banana]");
IPivotFormula formula = pivotTable.getPivotFormulas().get(0);
index - 要检索的透视公式的索引。IPivotFormula。