テンプレート ファイルからワークブックを読み込む際のデータの種類のフィルタリング
Contents
[
Hide
]
テンプレート ファイルからワークブックを作成するときに、どの種類のデータを読み込むかを指定したい場合があります。ロードされたデータをフィルタリングすると、特別な目的のためにパフォーマンスを向上させることができます。LightCell API .をご利用くださいLoadOptions.LoadFilterこの目的のためのプロパティ。
次のサンプル コードは、ワークブックをテンプレートファイル指定されたリンクからダウンロードできます。次のスクリーンショットは、テンプレートファイルまた、赤と黄色の背景のデータはロードされないことも説明されています。LoadOptions.LoadFilterプロパティはに設定されていますLoadDataFilterOptions.Shape
次のスクリーンショットは、出力 PDF指定されたリンクからダウンロードできます。ここでわかるように、赤色と黄色の背景のデータは存在しませんが、すべての形状が存在します。
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-.NET | |
//Source directory | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
//Output directory | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
// Set the load options, we only want to load shapes and do not want to load data | |
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx); | |
loadOptions.LoadFilter = new LoadFilter(LoadDataFilterOptions.All & ~LoadDataFilterOptions.Chart); | |
// Create workbook object from sample excel file using load options | |
Workbook workbook = new Workbook(sourceDir + "sampleFilterChars.xlsx", loadOptions); | |
// Save the output in pdf format | |
workbook.Save(outputDir + "sampleFilterChars_out.pdf", SaveFormat.Pdf); |