Modifier la disposition du tableau croisé dynamique
Comment modifier la disposition d’un tableau croisé dynamique dans MS-Excel
Microsoft Excel vous permet de modifier la disposition du tableau croisé dynamique en utilisant les commandes de menu Outils de tableau croisé dynamique > Conception > Disposition de rapport. Vous pouvez modifier la disposition de ces trois formes.
- Afficher sous forme compacte
- Afficher sous forme de plan
- Afficher sous forme tabulaire
Comment changer la disposition du tableau croisé dynamique en utilisant la bibliothèque Excel Aspose.Cells pour Python
La bibliothèque Excel Aspose.Cells pour Python fournit également les méthodes PivotTable.show_in_compact_form(), PivotTable.show_in_outline_form() et PivotTable.show_in_tabular_form() pour modifier la disposition du tableau croisé dynamique sous ces trois formes.
Code d’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.
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create workbook object from source excel file | |
workbook = Workbook(dataDir + "pivotTable_sample.xlsx") | |
# Access first worksheet | |
worksheet = workbook.worksheets[0] | |
# Access first pivot table | |
pivotTable = worksheet.pivot_tables[0] | |
# 1 - Show the pivot table in compact form | |
pivotTable.show_in_compact_form() | |
# Refresh the pivot table | |
pivotTable.refresh_data() | |
pivotTable.calculate_data() | |
# Save the output | |
workbook.save(dataDir + "CompactForm_out.xlsx") | |
# 2 - Show the pivot table in outline form | |
pivotTable.show_in_outline_form() | |
# Refresh the pivot table | |
pivotTable.refresh_data() | |
pivotTable.calculate_data() | |
# Save the output | |
workbook.save(dataDir + "OutlineForm_out.xlsx") | |
# 3 - Show the pivot table in tabular form | |
pivotTable.show_in_tabular_form() | |
# Refresh the pivot table | |
pivotTable.refresh_data() | |
pivotTable.calculate_data() | |
# Save the output | |
workbook.save(dataDir + "TabularForm_out.xlsx") |