تعيين العنوان لأيقونة OLE
Contents
[
Hide
]
تمت إضافة طرق جديدة getSubstitutePictureTitle و setSubstitutePictureTitle إلى واجهة IOleObjectFrame وفئة OleObjectFrame. تتيح هذه الطرق الحصول على عنوان أو تغييره أو ضبطه لأيقونة OLE. يعرض جزء الشيفرة أدناه مثالاً على إنشاء كائن Excel وتعيين عنوانه.
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
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SubstitutePictureTitleOfOLEObjectFrame.class); | |
String oleSourceFile = dataDir + "book1.xlsx"; | |
String oleIconFile = dataDir + "aspose-logo.jpg"; | |
Presentation pres = new Presentation(); | |
try | |
{ | |
IPPImage image = null; | |
ISlide slide = pres.getSlides().get_Item(0); | |
// Add Ole objects | |
byte[] allbytes = Files.readAllBytes(Paths.get(oleSourceFile)); | |
IOleObjectFrame oof = slide.getShapes().addOleObjectFrame(20, 20, 50, 50, "Excel.Sheet.12", allbytes); | |
oof.setObjectIcon(true); | |
// Add image object | |
byte[] imgBuf = Files.readAllBytes(Paths.get(oleIconFile)); | |
ByteArrayInputStream bais = new ByteArrayInputStream(imgBuf); | |
try { | |
image = pres.getImages().addImage(ImageIO.read(bais)); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
oof.getSubstitutePictureFormat().getPicture().setImage(image); | |
// Set caption to OLE icon | |
oof.setSubstitutePictureTitle("Caption example"); | |
} finally { | |
pres.dispose(); | |
} | |