ピボットテーブルのレイアウト変更
Contents
[
Hide
]
Microsoft Excel では、ピボット テーブルのレイアウトを次のように変更できます。ピボットテーブル ツール > デザイン > レポート レイアウトメニューコマンド。この3つのフォームでレイアウトを変更できます
- コンパクトに表示
- アウトライン形式で表示
- 表形式で表示
Aspose.Cellsも提供していますPivotTable.ShowInCompactForm(), PivotTable.ShowInOutlineForm()とPivotTable.ShowInTabularForm()これら 3 つの形式でピボット テーブルのレイアウトを変更するメソッド。
次のサンプル コードは、最初にピボット テーブルをコンパクトなフォルム、次にピボットテーブルを表示しますアウトラインフォームそして最後にピボットテーブルを表示します表形式.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |