Filtering the kind of data while loading the workbook from 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 LoadOptions.LoadFilter 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-.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); |