طرق مختلفة لفتح الملفات
Contents
[
Hide
]
باستخدام Aspose.Cells ، يمكن فتح الملفات ، على سبيل المثال لاسترداد البيانات ، أو استخدام قالب المصمم لتسريع عملية التطوير. يمكن لـ Aspose.Cells فتح مجموعة من الملفات المختلفة ، مثل Microsoft جداول بيانات Excel (XLS ، XLSX ، XLSM ، XLSB) ، ملفات CSV أو TabDelimited.
فتح ملف عبر مسار
يمكن للمطورين فتح ملف Excel Microsoft باستخدام مسار الملف الخاص به على الكمبيوتر المحلي عن طريق تحديده في ملفIWorkbookمنشئ الطبقة. ما عليك سوى تمرير المسار في المُنشئ كسلسلة. سوف يقوم Aspose.Cells باكتشاف نوع تنسيق الملف تلقائيًا.
This file contains hidden or 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-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Create Workbook object from an Excel file path | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(dirPath->StringAppend(new String("sampleExcelFile.xlsx"))); | |
//Show following message on console | |
Console::WriteLine(new String("Workbook opened successfully using file path.")); |
فتح ملف باستخدام الدفق
من الممكن أيضًا فتح ملف Excel كتدفق. للقيام بذلك ، استخدم إصدارًا محملاً بشكل زائد من المُنشئ يأخذ الامتدادمجرىالكائن الذي يحتوي على الملف.
This file contains hidden or 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-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Create a Stream object | |
intrusive_ptr<FileStream> fstream = new FileStream(dirPath->StringAppend(new String("sampleExcelFile.xlsx")), FileMode_Open); | |
//Create Workbook object from a Stream object | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(fstream); | |
//Show following message on console | |
Console::WriteLine(new String("Workbook opened successfully using stream.")); | |
//Close the Stream object | |
fstream->Close(); |