تحديث كائن Ole تلقائيًا عبر Microsoft Excel باستخدام Aspose.Cells
Contents
[
Hide
]
يوفر Aspose.Cells خاصية OleObject.AutoLoad لتحديث كائن OLE عند فتح ملف الإكسل في Microsoft Excel. نتيجة لهذه الخاصية، سيعرض الكائن OLE الصورة الصحيحة المُولدة بواسطة Microsoft Excel.
يقوم الكود العينة التالي بتحميل ملف الإكسل العينة الذي يحتوي على صورة OLE غير حقيقية. الكائن OLE هو في الواقع مستند Microsoft Word ولكن ملف الإكسل العينة يعرض صورة الحيوان بدلاً من صورة Microsoft Word. ولكن إذا فتحت ملف الإكسل الناتج، سترى Microsoft Excel عرض الصورة الصحيحة لـ OLE.
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 | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook object from your sample excel file | |
Workbook wb = new Workbook(dataDir + "sample.xlsx"); | |
// Access first worksheet | |
Worksheet sheet = wb.Worksheets[0]; | |
// Set auto load property of first ole object to true | |
sheet.OleObjects[0].AutoLoad = true; | |
// Save the worbook in xlsx format | |
wb.Save(dataDir + "RefreshOLEObjects_out.xlsx", SaveFormat.Xlsx); |