Cambiare il Layout della Tabella Pivot
Microsoft Excel consente di modificare il layout della tabella pivot utilizzando i comandi di menu Strumenti tabella pivot > Progettazione > Layout report. È possibile modificare il layout in queste tre forme.
- Mostra in forma compatta
- Mostra in forma di contorno
- Mostra in forma tabellare
Aspose.Cells fornisce anche metodi PivotTable.showInCompactForm(), PivotTable.showInOutlineForm() e PivotTable.showInTabularForm() per cambiare il layout della tabella pivot in queste tre forme.
Esempio
Il seguente codice di esempio mostra prima la tabella pivot in Forma compatta, quindi mostra la tabella pivot in Forma ad albero e infine mostra la tabella pivot in Forma tabellare.
// 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"); |