Ändra layouten för pivot tabell
Microsoft Excel låter dig ändra Layout för pivot-tabell med hjälp av menyalternativen PivotTable Tools > Design > Report Layout. Du kan ändra layouten i 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.
Följande exempelkod visar först pivot-tabellen i kompakt form, sedan visar den pivot-tabellen i kontursform och sist visar den pivot-tabellen i tabellform.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook object from source excel file | |
Workbook workbook = new Workbook(dataDir + "pivotTable_sample.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access first pivot table | |
PivotTable pivotTable = worksheet.PivotTables[0]; | |
// 1 - Show the pivot table in compact form | |
pivotTable.ShowInCompactForm(); | |
// Refresh the pivot table | |
pivotTable.RefreshData(); | |
pivotTable.CalculateData(); | |
// Save the output | |
workbook.Save(dataDir + "CompactForm_out.xlsx"); | |
// 2 - Show the pivot table in outline form | |
pivotTable.ShowInOutlineForm(); | |
// Refresh the pivot table | |
pivotTable.RefreshData(); | |
pivotTable.CalculateData(); | |
// Save the output | |
workbook.Save(dataDir + "OutlineForm_out.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_out.xlsx"); |