Excel ファイルの読み込み中にピボット キャッシュ レコードを解析する
Contents
[
Hide
]
考えられる使用シナリオ
ピボット テーブルを作成すると、Microsoft Excel はソース データのコピーを取得し、ピボット キャッシュに保存します。ピボット キャッシュは、Microsoft Excel のメモリ内に保持されます。見ることはできませんが、ピボット テーブルを作成したり、スライサーの選択を変更したり、行/列を移動したりするときに、ピボット テーブルが参照するデータです。これにより、Microsoft Excel がピボット テーブルの変更に非常に反応しやすくなりますが、ファイルのサイズが 2 倍になることもあります。結局、ピボット キャッシュはソース データの単なる複製であるため、ファイル サイズが潜在的に 2 倍になることは理にかなっています。
Workbook オブジェクト内に Excel ファイルをロードするときに、ピボット キャッシュのレコードもロードするかどうかを決定できます。LoadOptions.ParsingPivotCachedRecords財産。このプロパティのデフォルト値は間違い.ピボット キャッシュが非常に大きい場合は、パフォーマンスが向上する可能性があります。ただし、Pivot Cache のレコードもロードする場合は、このプロパティを次のように設定する必要があります。真実.
Excel ファイルの読み込み中にピボット キャッシュ レコードを解析する
次のサンプル コードは、LoadOptions.ParsingPivotCachedRecords財産。それはサンプル Excel ファイルピボット キャッシュ レコードの解析中。次に、ピボット テーブルを更新して、出力エクセルファイル.
サンプルコード
This file contains hidden or 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-Java | |
//Create load options | |
LoadOptions options = new LoadOptions(); | |
//Set ParsingPivotCachedRecords true, default value is false | |
options.setParsingPivotCachedRecords(true); | |
//Load the sample Excel file containing pivot table cached records | |
Workbook wb = new Workbook("sampleParsingPivotCachedRecordsWhileLoadingExcelFile.xlsx", options); | |
//Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Access first pivot table | |
PivotTable pt = ws.getPivotTables().get(0); | |
//Set refresh data flag true | |
pt.setRefreshDataFlag(true); | |
//Refresh and calculate pivot table | |
pt.refreshData(); | |
pt.calculateData(); | |
//Set refresh data flag false | |
pt.setRefreshDataFlag(false); | |
//Save the output Excel file | |
wb.save("outputParsingPivotCachedRecordsWhileLoadingExcelFile.xlsx"); |