リンクされた Ole オブジェクトの表示ラベルにアクセスして変更する
Contents
[
Hide
]
考えられる使用シナリオ
Microsoft Excel では、次のスクリーンショットに示すように、Ole オブジェクトの表示ラベルを変更できます。 Aspose.Cells API を使用して、Ole オブジェクトの表示ラベルにアクセスまたは変更することもできます。OleObject.Label財産。
リンクされた Ole オブジェクトの表示ラベルにアクセスして変更する
次のサンプル コードを参照してください。サンプル Excel ファイルOle オブジェクトが含まれています。コードは Ole オブジェクトにアクセスし、そのラベルをサンプル API から Aspose API に変更します。参考として、サンプル コードがサンプル Excel ファイルに与える影響を示す以下のコンソール出力を参照してください。
サンプルコード
This file contains hidden or 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
// 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