الوصول إلى وتعديل التسمية العرضية لكائن Ole المرتبط
سيناريوهات الاستخدام المحتملة
تسمح لك Microsoft Excel بتغيير تسمية عرض كائن Ole كما هو موضح في الصورة التالية. يمكنك أيضًا الوصول إلى أو تعديل تسمية عرض الكائن Ole باستخدام واجهات برمجة التطبيقات Aspose.Cells مع خاصية OleObject.Label
الوصول إلى وتعديل التسمية العرضية لكائن Ole المرتبط
يرجى الاطلاع على كود العينة التالي، يقوم بتحميل ملف الإكسل عينة الذي يحتوي على كائن Ole. يقوم الكود بالوصول إلى كائن Ole وتغيير تسميته من Sample APIs إلى Aspose APIs. الرجاء الاطلاع على إخراج وحدة التحكم المطبوع أدناه الذي يظهر تأثير كود العينة على ملف الإكسل العينة للإشارة.
الكود المثالي
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load the sample Excel file | |
Workbook wb = new Workbook("sampleAccessAndModifyLabelOfOleObject.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Access first Ole Object | |
Aspose.Cells.Drawing.OleObject oleObject = ws.OleObjects[0]; | |
//Display the Label of the Ole Object | |
Console.WriteLine("Ole Object Label - Before: " + oleObject.Label); | |
//Modify the Label of the Ole Object | |
oleObject.Label = "Aspose APIs"; | |
//Save workbook to memory stream | |
MemoryStream ms = new MemoryStream(); | |
wb.Save(ms, SaveFormat.Xlsx); | |
//Set the workbook reference to null | |
wb = null; | |
//Load workbook from memory stream | |
wb = new Workbook(ms); | |
//Access first worksheet | |
ws = wb.Worksheets[0]; | |
//Access first Ole Object | |
oleObject = ws.OleObjects[0]; | |
//Display the Label of the Ole Object that has been modified earlier | |
Console.WriteLine("Ole Object Label - After: " + oleObject.Label); |
مخرجات الوحدة
Ole Object Label - Before: Sample APIs
Ole Object Label - After: Aspose APIs