整合功能
Contents
[
Hide
]
整合功能
Aspose.Cells 可用于将 ConsolidationFunction 应用于数据透视表的数据字段(或值字段)。在Microsoft Excel中,您可以右键单击值字段,然后选择值字段设置…选项,然后选择选项卡值汇总依据.从那里,您可以选择您选择的任何 ConsolidationFunction,例如 Sum、Count、Average、Max、Min、Product、Distinct Count 等。
Aspose.Cells提供整合功能支持以下合并功能的枚举。
- 合并函数.SUM
- 合并函数.COUNT
- 合并函数.AVERAGE
- 合并函数.MAX
- 合并函数.MIN
- 合并函数.PRODUCT
- 合并函数.COUNT_NUMS
- 合并函数.STD_DEV
- 合并函数.STD_DEVP
- 合并函数.VAR
- 合并函数
- 合并函数.DISTINCT_COUNT
将 ConsolidationFunction 应用于数据透视表的数据字段
以下代码适用平均的合并功能到第一个数据字段(或值字段)和标准偏差合并功能到第二个数据字段(或值字段)。
可以从此处下载示例源文件和输出文件以测试示例代码:
This file contains 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 | |
// The path to the resource directory | |
// Create workbook from source excel file | |
Workbook workbook = new Workbook("source.xlsx"); | |
// Access the second worksheet of the workbook | |
Worksheet worksheet = workbook.getWorksheets().get(1); | |
// Access the first pivot table of the worksheet | |
PivotTable pivotTable = worksheet.getPivotTables().get(0); | |
// Apply AVERAGE consolidation function to first data field | |
pivotTable.getDataFields().get(0).setFunction(ConsolidationFunction.AVERAGE); | |
// Apply STD_DEV consolidation function to second data field | |
pivotTable.getDataFields().get(1).setFunction(ConsolidationFunction.STD_DEV); | |
// Calculate the data to make changes affect | |
pivotTable.calculateData(); | |
// Saving the Excel file | |
workbook.save("output.xlsx"); |
Microsoft 仅 Excel 2013 支持 DistinctCount 合并函数。