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(); | |
} | |