Modifier la disposition du tableau croisé dynamique
Microsoft Excel vous permet de modifier la mise en page du tableau croisé dynamique à l’aide des commandes de menu Outils de tableau croisé dynamique > Création > Disposition du rapport. Vous pouvez changer la mise en page sous ces trois formes.
- Afficher sous forme compacte
- Afficher sous forme de plan
- Afficher sous forme tabulaire
Aspose.Cells fournit également les méthodes PivotTable.showInCompactForm(), PivotTable.showInOutlineForm() et PivotTable.showInTabularForm() pour modifier la mise en page du tableau croisé dynamique sous ces trois formes.
Exemple
Le code d’exemple suivant montre d’abord le tableau croisé dynamique sous Forme compacte, puis il montre le tableau croisé dynamique sous Forme de plan et enfin, il montre le tableau croisé dynamique sous Forme tabulaire.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ChangingLayoutofPivotTable.class); | |
// Create workbook object from source excel file | |
Workbook workbook = new Workbook(dataDir + "source.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Access first pivot table | |
PivotTable pivotTable = worksheet.getPivotTables().get(0); | |
// 1 - Show the pivot table in compact form | |
pivotTable.showInCompactForm(); | |
// Refresh the pivot table | |
pivotTable.refreshData(); | |
pivotTable.calculateData(); | |
// Save the output | |
workbook.save("CompactForm.xlsx"); | |
// 2 - Show the pivot table in outline form | |
pivotTable.showInOutlineForm(); | |
// Refresh the pivot table | |
pivotTable.refreshData(); | |
pivotTable.calculateData(); | |
// Save the output | |
workbook.save("OutlineForm.xlsx"); | |
// 3 - Show the pivot table in tabular form | |
pivotTable.showInTabularForm(); | |
// Refresh the pivot table | |
pivotTable.refreshData(); | |
pivotTable.calculateData(); | |
// Save the output | |
workbook.save(dataDir + "TabularForm.xlsx"); |