显示报告过滤页面选项
Contents
[
Hide
]
显示报告筛选页面选项
Excel 支持创建数据透视表、添加报表筛选器并启用“显示报表筛选器页面”选项。 Aspose.Cells 还支持此功能以在创建的数据透视表上启用“显示报表筛选页面”选项。以下是在 Excel 中显示该选项的屏幕。
由于此选项,创建的工作簿包含更多工作表。它将报表筛选器的每个可能值拆分到一个单独的工作表中。在这个例子中,它有一个关于“位置”的过滤器,数据有三个不同的位置(A、B、C)。此功能添加了 3 个名为 A、B、C 的额外工作表,它们是相同的数据透视表,但具有预选选项 A、B 和 C。
示例文件和输出文件可以从以下链接下载:
源代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Load template file | |
Workbook wb = new Workbook(srcDir + "samplePivotTable.xlsx"); | |
// Get first pivot table in the worksheet | |
PivotTable pt = wb.getWorksheets().get(1).getPivotTables().get(0); | |
// Set pivot field | |
pt.showReportFilterPage(pt.getPageFields().get(0)); | |
// Set position index for showing report filter pages | |
pt.showReportFilterPageByIndex(pt.getPageFields().get(0).getPosition()); | |
// Set the page field name | |
pt.showReportFilterPageByName(pt.getPageFields().get(0).getName()); | |
// Save the output file | |
wb.save(outDir + "outputSamplePivotTable.xlsx"); |