連結機能
Contents
[
Hide
]
連結機能
Aspose.Cells を使用して、ConsolidationFunction をピボット テーブルのデータ フィールド (または値フィールド) に適用できます。 Microsoft Excel では、値フィールドを右クリックして、値フィールドの設定…オプションを選択し、タブを選択します値の集計基準.そこから、Sum、Count、Average、Max、Min、Product、Distinct Count などの任意の ConsolidationFunction を選択できます。
Aspose.Cells提供連結機能次の連結関数をサポートするための列挙。
- ConsolidationFunction.Average
- ConsolidationFunction.Count
- ConsolidationFunction.CountNums
- ConsolidationFunction.DistinctCount
- ConsolidationFunction.Max
- ConsolidationFunction.Min
- ConsolidationFunction.Product
- ConsolidationFunction.StdDev
- ConsolidationFunction.StdDevp
- ConsolidationFunction.Sum
- ConsolidationFunction.Var
- ConsolidationFunction.Varp
ConsolidationFunction をピボット テーブルのデータ フィールドに適用する
次のコードが適用されます平均連結関数を最初のデータ フィールド (または値フィールド) に適用し、DistinctCount 2 番目のデータ フィールド (または値フィールド) への連結関数。
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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook from source excel file | |
Workbook workbook = new Workbook(dataDir + "Book.xlsx"); | |
// Access the first worksheet of the workbook | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access the first pivot table of the worksheet | |
PivotTable pivotTable = worksheet.PivotTables[0]; | |
// Apply Average consolidation function to first data field | |
pivotTable.DataFields[0].Function = ConsolidationFunction.Average; | |
// Apply DistinctCount consolidation function to second data field | |
pivotTable.DataFields[1].Function = ConsolidationFunction.DistinctCount; | |
// Calculate the data to make changes affect | |
pivotTable.CalculateData(); | |
// Saving the Excel file | |
workbook.Save(dataDir + "output.xlsx"); | |
DistinctCount 連結関数は、Microsoft Excel 2013 のみでサポートされています。