Arbeiten mit Datenanzeigeformaten von DataField in Pivot-Tabellen
Contents
[
Hide
]
Aspose.Cells unterstützt alle Datenanzeigeformate von DataField.
Anzeigeformatoption „Rang vom kleinsten zum größten“ und „Rang vom größten zum kleinsten“.
Aspose.Cells bietet die Möglichkeit, die Anzeigeformatoption für Pivot-Felder festzulegen. Dafür sorgt die APIPivotField.DataDisplayFormat Eigentum. Um vom größten zum kleinsten zu rangieren, können Sie die festlegenPivotField.DataDisplayFormatEigentum zuPivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST. Das folgende Code-Snippet veranschaulicht das Festlegen der Optionen für das Anzeigeformat.
Beispielquell- und -ausgabedateien können hier zum Testen des Beispielcodes heruntergeladen werden:
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"); |