ピボットテーブルでのデータフィールドの表示形式を操作する
Contents
[
Hide
]
Aspose.Cells for Python via .NETはすべてのDataFieldのデータ表示形式をサポートしています
「最小から最大へのランク」と「最大から最小へのランク」の表示形式オプションを設定する方法
Aspose.Cells for Python via .NETでは、ランク最大から最小への表示形式オプションを設定するために、PivotField.data_display_format プロパティが提供されています。最大から最小へのランクを設定するには、PivotField.data_display_format プロパティをPivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST に設定することができます。次のコードスニペットは表示形式オプションの設定を示しています。
サンプルソースと出力ファイルは、テスト用のサンプルコードをダウンロードできます:
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
from aspose.cells import Workbook | |
from aspose.cells.pivot import PivotFieldDataDisplayFormat | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# directories | |
sourceDir = RunExamples.Get_SourceDirectory() | |
outputDir = RunExamples.Get_OutputDirectory() | |
# Load a template file | |
workbook = Workbook(sourceDir + "PivotTableSample.xlsx") | |
# Get the first worksheet | |
worksheet = workbook.worksheets[0] | |
pivotIndex = 0 | |
# Accessing the PivotTable | |
pivotTable = worksheet.pivot_tables[pivotIndex] | |
# Accessing the data fields. | |
pivotFields = pivotTable.data_fields | |
# Accessing the first data field in the data fields. | |
pivotField = pivotFields[0] | |
# Setting data display format | |
pivotField.data_display_format = PivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST | |
pivotTable.calculate_data() | |
# Saving the Excel file | |
workbook.save(outputDir + "PivotTableDataDisplayFormatRanking_out.xlsx") |