テンプレートファイルからワークブックをロードする際にデータの種類をフィルタリングする
Contents
[
Hide
]
時々、テンプレートファイルからワークブックを作成する際にロードされるデータの種類を指定したい場合があります。ロードされるデータをフィルタリングすることで、特にLightCells APIを使用する際に、特定の目的に向けてパフォーマンスを向上させることができます。この目的のためにLoadOptions.LoadFilterプロパティを使用してください。
指定されたリンクからダウンロードできるテンプレートファイルを使用して、ワークブックをロードする際にシェイプオブジェクトのみをロードするサンプルコードを以下に示します。以下のスクリーンショットにはテンプレートファイルの内容と、赤色および黄色の背景のデータがロードされないことを説明したものが表示されています。これはLoadOptions.LoadFilterプロパティがLoadDataFilterOptions.Shapeに設定されているためです。
指定されたリンクからダウンロードできる出力PDFです。ここでは、赤色および黄色の背景のデータが存在しない一方、すべての形状が存在することが分かります。
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 | |
//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); |