فتح ملفات إكسل من إصدارات مايكروسوفت المختلفة
كيفية فتح ملفات من إصدارات مايكروسوفت إكسل المختلفة
غالبًا ما يجب على تطبيق أن يكون قادرًا على فتح ملفات Microsoft Excel التي تم إنشاؤها في إصدارات مختلفة، على سبيل المثال، Microsoft Excel 95،97، أو Microsoft Excel 2007/2010/2013/2016/2019 وOffice 365. قد تحتاج إلى تحميل ملف بأحد صيغ متعددة، بما في ذلك XLS، XLSX، XLSM، XLSB، SpreadsheetML، تنسيق الجدول المفصول بالفواصل أو TSV، CSV، ODS، وما إلى ذلك. استخدم البناء، أو حدد نوع الفئة Workbook باستخدام سمة FileFormat التي تحدد التنسيق باستخدام فئة التعداد FileFormatType.
تحتوي فئة FileFormatType على العديد من تنسيقات الملفات المحددة مسبقًا بعضها مذكور أدناه.
أنواع تنسيق الملفات | الوصف |
---|---|
Csv | يمثل ملف CSV |
Excel97To2003 | يمثل ملف Excel 97-2003 |
Xlsx | يمثل ملف Excel 2007/2010/2013/2016/2019 و Office 365 XLSX |
Xlsm | يمثل ملف Excel 2007/2010/2013/2016/2019 و Office 365 XLSM |
Xltx | يمثل ملف XLTX قالب Excel 2007/2010/2013/2016/2019 و Office 365 |
Xltm | يمثل ملف XLTM Excel 2007/2010/2013/2016/2019 و Office 365 القادر على تشغيل الماكرو |
Xlsb | يمثل ملف XLSB بتنسيق Excel 2007/2010/2013/2016/2019 و Office 365 |
SpreadsheetML | يمثل ملف SpreadsheetML |
Tsv | يمثل ملف بقيم مفصولة بواسطة علامة التبويب |
TabDelimited | يمثل ملف نصي بقيم مفصولة بواسطة علامة التبويب |
Ods | يمثل ملف ODS |
Html | يمثل ملف HTML |
Mhtml | يمثل ملف MHTML |
فتح ملفات Microsoft Excel 95/5.0
لفتح ملف Microsoft Excel 95/5.0، استخدم LoadOptions وقم بتعيين السمة ذات الصلة لفئة LoadOptions لقالب الملف الذي سيتم تحميله. يمكن تنزيل ملف عيني لاختبار هذه الميزة من الرابط التالي:
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Get the Excel file into stream | |
using (FileStream stream = new FileStream(dataDir + "Excel95_5.0.xls", FileMode.Open)) | |
{ | |
// Instantiate LoadOptions specified by the LoadFormat. | |
LoadOptions loadOptions1 = new LoadOptions(LoadFormat.Excel97To2003); | |
// Create a Workbook object and opening the file from the stream | |
Workbook wbExcel95 = new Workbook(stream, loadOptions1); | |
Console.WriteLine("Microsoft Excel 95/5.0 workbook opened successfully!"); | |
} |
فتح ملفات Microsoft Excel 97 - 2003
لفتح ملف Microsoft Excel 97 - 2003، استخدم LoadOptions وقم بتعيين السمة ذات الصلة لفئة LoadOptions لقالب الملف الذي سيتم تحميله.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Get the Excel file into stream | |
using (FileStream stream = new FileStream(dataDir + "Book_Excel97_2003.xls", FileMode.Open)) | |
{ | |
// Instantiate LoadOptions specified by the LoadFormat. | |
LoadOptions loadOptions1 = new LoadOptions(LoadFormat.Excel97To2003); | |
// Create a Workbook object and opening the file from the stream | |
Workbook wbExcel97 = new Workbook(stream, loadOptions1); | |
Console.WriteLine("Microsoft Excel 97 - 2003 workbook opened successfully!"); | |
} |
فتح ملفات Microsoft Excel 2007/2010/2013/2016/2019 و Office 365 بصيغة XLSX
لفتح تنسيق ملف Microsoft Excel 2007/2010/2013/2016/2019 وOffice 365، أي XLSX أو XLSB، حدد مسار الملف. يمكنك أيضًا استخدام LoadOptions وتعيين السمة/الخيارات ذات الصلة لفئة LoadOptions لقالب الملف الذي سيتم تحميله.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Opening Microsoft Excel 2007 Xlsx Files | |
// Instantiate LoadOptions specified by the LoadFormat. | |
LoadOptions loadOptions2 = new LoadOptions(LoadFormat.Xlsx); | |
// Create a Workbook object and opening the file from its path | |
Workbook wbExcel2007 = new Workbook(dataDir + "Book_Excel2007.xlsx", loadOptions2); | |
Console.WriteLine("Microsoft Excel 2007 - Office365 workbook opened successfully!"); |
فتح ملفات Excel المشفرة
من الممكن إنشاء ملفات Excel مشفرة باستخدام Microsoft Excel. لفتح ملف مشفر، استخدم فئة LoadOptions وقم بتعيين سماته وخياراته (على سبيل المثال، إعطاء كلمة مرور) لقالب الملف الذي سيتم تحميله. يمكن تنزيل ملف نموذجي لاختبار هذه الميزة من الرابط التالي:
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiate LoadOptions | |
LoadOptions loadOptions6 = new LoadOptions(); | |
// Specify the password | |
loadOptions6.Password = "1234"; | |
// Create a Workbook object and opening the file from its path | |
Workbook wbEncrypted = new Workbook(dataDir + "encryptedBook.xls", loadOptions6); | |
Console.WriteLine("Encrypted excel file opened successfully!"); |
تدعم Aspose.Cells أيضًا فتح ملفات Microsoft Excel 2007، 2010، 2013، 2016، 2019، Office 365 المحمية بكلمة مرور.