Установить подпись к значку 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(); | |
} | |