ピボット テーブルでの DataField のデータ表示形式の操作

「Rank Smallest to Largest」および「Rank Largest to Smallest」表示形式オプション

ASpose.Cells は、ピボット フィールドの表示形式オプションを設定する機能を提供します。このために、API はPivotField.DataDisplayFormat財産。最大から最小にランク付けするには、PivotField.DataDisplayFormatプロパティへPivotFieldDataDisplayFormat.RankLargestToSmallest.次のコード スニペットは、表示形式オプションの設定を示しています。

サンプル ソースと出力ファイルは、サンプル コードをテストするために、ここからダウンロードできます。

ソース Excel ファイル

出力 Excel ファイル

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// directories
string sourceDir = RunExamples.Get_SourceDirectory();
string outputDir = RunExamples.Get_OutputDirectory();
// Load a template file
Workbook workbook = new Workbook(sourceDir + "PivotTableSample.xlsx");
// Get the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
int pivotIndex = 0;
// Accessing the PivotTable
PivotTable pivotTable = worksheet.PivotTables[pivotIndex];
// Accessing the data fields.
PivotFieldCollection pivotFields = pivotTable.DataFields;
// Accessing the first data field in the data fields.
PivotField pivotField = pivotFields[0];
// Setting data display format
pivotField.ShowValuesSetting.CalculationType = PivotFieldDataDisplayFormat.RankLargestToSmallest;
pivotTable.CalculateData();
// Saving the Excel file
workbook.Save(outputDir + "PivotTableDataDisplayFormatRanking_out.xlsx");