قم بتصفية مشروع VBA أثناء تحميل مصنف
Contents
[
Hide
]
قم بتصفية مشروع VBA أثناء تحميل مصنف Excel في C#
تحتوي بعض ملفات .xlsm / .xslb على كمية كبيرة جدًا من وحدات الماكرو (أو وحدات ماكرو طويلة جدًا). سيقوم Aspose.Cells بتحميل هذه البيانات (التعريفية) دون قيد أو شرط عند فتح مثل هذه المصنفات. قد تحتاج إلى التحكم في هذا بالرغم من ذلكLoadDataFilterOptions عندما تحتاج حقًا فقط إلى استخراج أسماء الأوراق لعدد كبير من المصنفات ، وبالتالي تخطي هذا المحتوى غير الضروري. يتم توفير هذا الفلتر من خلال تقديم خيار جديد ،LoadDataFilterOptions.VBA.
عينة من الرموز
يقوم نموذج التعليمات البرمجية التالي بتحميل مصنف بحيث يتم تصفية VBA فقط. يمكن تنزيل نموذج ملف لاختبار هذه الميزة من الرابط التالي:
sampleMacroEnabledWorkbook.xlsm
This file contains 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-.NET | |
// Set the load options, we do not want to load VBA | |
LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto); | |
loadOptions.LoadFilter = new LoadFilter(LoadDataFilterOptions.All & ~LoadDataFilterOptions.VBA); | |
// Create workbook object from sample excel file using load options | |
Workbook book = new Workbook(sourceDir + "sampleMacroEnabledWorkbook.xlsm", loadOptions); | |
// Save the output in pdf format | |
book.Save(outputDir + "OutputSampleMacroEnabledWorkbook.xlsm", SaveFormat.Xlsm); |