ピボット テーブルでの DataField のデータ表示形式の操作
Contents
[
Hide
]
Aspose.Cells は、DataField のすべてのデータ表示形式をサポートしています。
「Rank Smallest to Largest」および「Rank Largest to Smallest」表示形式オプション
Aspose.Cells は、ピボット フィールドの表示形式オプションを設定する機能を提供します。このために、API はPivotField.DataDisplayFormat財産。最大から最小にランク付けするには、PivotField.DataDisplayFormatプロパティへPivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST.次のコード スニペットは、表示形式オプションの設定を示しています。
サンプル ソースと出力ファイルは、サンプル コードをテストするために、ここからダウンロードできます。
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 | |
// directories | |
String sourceDir = Utils.Get_SourceDirectory(); | |
String outputDir = Utils.Get_OutputDirectory(); | |
// Load a template file | |
Workbook workbook = new Workbook(sourceDir + "PivotTableSample.xlsx"); | |
// Get the first worksheet | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
int pivotIndex = 0; | |
// Get the pivot tables in the sheet | |
PivotTable pivotTable = sheet.getPivotTables().get(pivotIndex); | |
// Accessing the data fields. | |
PivotFieldCollection pivotFields = pivotTable.getDataFields(); | |
// Accessing the first data field in the data fields. | |
PivotField pivotField = pivotFields.get(0); | |
// Setting data display format | |
pivotField.setDataDisplayFormat(PivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST); | |
pivotTable.calculateData(); | |
// Saving the Excel file | |
workbook.save(outputDir + "PivotTableDataDisplayFormatRanking_out.xlsx"); |