Cambiando el Diseño de la Tabla Dinámica
Microsoft Excel te permite cambiar el diseño de la Tabla Dinámica utilizando los comandos de menú Herramientas de tabla dinámica > Diseño > Informe. Puedes cambiar el diseño en estas tres formas
- Mostrar en Forma Compacta
- Mostrar en Forma de Esquema
- Mostrar en forma tabular
Aspose.Cells también proporciona los métodos PivotTable.showInCompactForm(), PivotTable.showInOutlineForm() y PivotTable.showInTabularForm() para cambiar el diseño de la tabla dinámica en estas tres formas.
Ejemplo
El siguiente código de ejemplo primero muestra la tabla dinámica en Forma Compacta, luego muestra la tabla dinámica en Forma de Esquema y por último, muestra la tabla dinámica en Forma Tabular.
// 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"); |