从模板文件加载工作簿时过滤数据类型
Contents
[
Hide
]
有时,您希望指定在从模板文件构建工作簿时应加载哪种数据。过滤加载的数据可以提高您的特殊用途的性能,尤其是在使用时LightCells API .请使用LoadOptions.getLoadFilter().setLoadDataFilterOptions为此目的的财产。
从模板文件加载工作簿时筛选数据类型
以下示例代码在从模板文件您可以从给定的链接下载。
以下屏幕截图显示了模板文件内容并解释了红色和黄色背景的数据将不会被加载,因为LoadOptions.getLoadFilter().setLoadDataFilterOptions属性已设置为加载数据过滤器选项.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-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(FilterDataWhileLoadingWorkbook.class) + "TechnicalArticles/"; | |
// Set the load options, we only want to load shapes and do not want to load data | |
LoadOptions opts = new LoadOptions(LoadFormat.XLSX); | |
opts.getLoadFilter().setLoadDataFilterOptions(LoadDataFilterOptions.SHAPE); | |
// Create workbook object from sample excel file using load options | |
Workbook wb = new Workbook(dataDir + "sampleFilterDataWhileLoadingWorkbook.xlsx", opts); | |
// Save the output in PDF format | |
wb.save(dataDir + "sampleFilterDataWhileLoadingWorkbook_out.pdf", SaveFormat.PDF); |