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

Contents
[ ]

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

待办事项:图片_替代_文本

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

待办事项:图片_替代_文本

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