ピボットテーブルでのデータフィールドの表示形式を操作する

「最小から最大への順位付け」と「最大から最小への順位付け」表示形式オプション

ASpose.Cellsは、ピボットフィールドの表示形式オプションを設定する機能を提供しています。このためのAPIはPivotShowValuesSetting.setCalculationTypeプロパティを提供しています。最大から最小への順位付けを行うには、PivotShowValuesSetting.setCalculationTypeプロパティをPivotFieldDataDisplayFormat.RankLargestToSmallestに設定できます。次のコードスニペットは、表示形式オプションの設定方法を示しています。

サンプルソースと出力ファイルは、テスト用のサンプルコードをダウンロードできます:

ソースExcelファイル

出力Excelファイル

const AsposeCells = require("aspose.cells.node");
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// directories
var sourceDir = RunExamples.Get_SourceDirectory()
var outputDir = RunExamples.Get_OutputDirectory()
// Load a template file
var workbook = new AsposeCells.Workbook(sourceDir + "PivotTableSample.xlsx");
// Get the first worksheet
var worksheet = workbook.getWorksheets().get(0);
var pivotIndex = 0;
// Accessing the PivotTable
var pivotTable = worksheet.getPivotTables().get(pivotIndex);
// Accessing the data fields.
var pivotFields = pivotTable.getDataFields();
// Accessing the first data field in the data fields.
var pivotField = pivotFields.get(0);
// Setting data display format
pivotField.getShowValuesSetting().setCalculationType(AsposeCells.PivotFieldDataDisplayFormat.RankLargestToSmallest);
pivotTable.calculateData();
// Saving the Excel file
workbook.save(outputDir + "PivotTableDataDisplayFormatRanking_out.xlsx");