从模板文件加载工作簿时过滤数据类型

Contents
[ ]

以下示例代码仅在从模板文件加载工作簿时加载形状对象,您可以从给定链接下载模板文件。下面的屏幕截图显示了模板文件的内容,并且解释了红色和黄色背景中的数据将不会被加载,因为LoadOptions.LoadFilter属性已设置为LoadDataFilterOptions.Shape

todo:image_alt_text

下面的屏幕截图显示了您可以从给定链接下载的输出PDF。在这里,您可以看到红色和黄色背景中的数据不存在,但所有形状都在那里。

todo:image_alt_text

// 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);