تصفية نوع البيانات أثناء تحميل ورق العمل من ملف النموذج
يقوم الكود العيني التالي بتحميل كائنات الشكل فقط أثناء تحميل الدفتر من ملف النموذج الذي يمكنك تحميله من الرابط المتوفر. توضح اللقطة الشاشية التالية محتويات ملف النموذج وتشرح أيضًا أنه لن يتم تحميل البيانات ذات اللون الأحمر والخلفية الصفراء لأن الخاصية LoadOptions.LoadFilter تم تعيينها على LoadDataFilterOptions.Shape.
تُظهر اللقطة الشاشية التالية ال 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); |