Filtering the kind of data while loading the workbook from template file
Filtering the kind of data while loading the workbook from a template file
The following sample code loads only shape objects while loading the workbook from the template file which you can download from the given link.
The following screenshot shows the template file contents and also explains that the data in Red color and Yellow background will not be loaded because the LoadOptions.getLoadFilter().setLoadDataFilterOptions property has been set to LoadDataFilterOptions.SHAPE.
The following screenshot shows the output PDF which you can download from the given link. Here you can see, the data in Red color and Yellow background is not present but all shapes are there.
// 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); |