Pivot Tabloda DataField'in veri görüntüleme biçimleriyle çalışma
Contents
[
Hide
]
Aspose.Cells, DataField’ın tüm veri görüntüleme formatlarını destekler.
“En Küçükten En Büyüğe Sırala” ve “En Büyükten En Küçüğe Sırala” görüntü formatı seçeneği
Aspose.Cells, pivot alanlar için görüntüleme formatı seçeneğini belirleme yeteneği sağlar. Bunun için API,PivotField.DataDisplayFormat Emlak. En büyükten en küçüğe sıralamak içinPivotField.DataDisplayFormatmülkiyetPivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST. Aşağıdaki kod parçacığı, görüntü formatı seçeneklerini ayarlamayı gösterir.
Örnek kodu test etmek için örnek kaynak ve çıktı dosyaları buradan indirilebilir:
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-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"); |