الوصول إلى وتعديل التسمية العرضية لكائن Ole المرتبط
سيناريوهات الاستخدام المحتملة
يُتيح Microsoft Excel لك تغيير التسمية العرضية لكائن Ole كما هو موضح في اللقطة الشاشية التالية. يمكنك أيضًا الوصول إلى أو تعديل التسمية العرضية لكائن Ole باستخدام واجهات برمجة التطبيق (API) لـ Aspose.Cells مع خاصية OleObject.Label.
الوصول إلى وتعديل التسمية العرضية لكائن Ole المرتبط
الرجاء رؤية رمز العينة التالي، فهو يحمل ملف إكسل عينة الذي يحتوي على كائن Ole. يقوم الرمز بالوصول إلى كائن Ole وتغيير تسميته من Sample APIs إلى Aspose APIs. الرجاء رؤية مخرجات الوحدة التحكم الواردة أدناه التي تظهر تأثير الرمز العيني على ملف Excel العيني للإشارة.
الكود المثالي
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Load the sample Excel file | |
Workbook wb = new Workbook("sampleAccessAndModifyLabelOfOleObject.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Access first Ole Object | |
OleObject oleObject = ws.getOleObjects().get(0); | |
//Display the Label of the Ole Object | |
System.out.println("Ole Object Label - Before: " + oleObject.getLabel()); | |
//Modify the Label of the Ole Object | |
oleObject.setLabel("Aspose APIs"); | |
//Save workbook to byte array output stream | |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
wb.save(baos, SaveFormat.XLSX); | |
//Convert output to input stream | |
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); | |
//Set the workbook reference to null | |
wb = null; | |
//Load workbook from byte array input stream | |
wb = new Workbook(bais); | |
//Access first worksheet | |
ws = wb.getWorksheets().get(0); | |
//Access first Ole Object | |
oleObject = ws.getOleObjects().get(0); | |
//Display the Label of the Ole Object that has been modified earlier | |
System.out.println("Ole Object Label - After: " + oleObject.getLabel()); |
مخرجات الوحدة
Ole Object Label - Before: Sample APIs
Ole Object Label - After: Aspose APIs