Ändra layouten för pivot tabell
Microsoft Excel gör det möjligt för dig att ändra layouten i Pivot-tabell med PivotTable Tools > Design > Rapport Layout-menyalternativ. Du kan ändra layouten på dessa tre former
- Visa i kompakt form
- Visa i kontursform
- Visa i tabellform
Aspose.Cells tillhandahåller också PivotTable.showInCompactForm(), PivotTable.showInOutlineForm() och PivotTable.showInTabularForm() metoder för att ändra layouten för pivot-tabell i dessa tre former.
Exempel
Den följande exempelkoden visar först Pivot-tabellen i Kompakt form, sedan visas Pivot-tabellen i Översiktlig form och sist visas Pivot-tabellen i Tabellform.
// 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"); |