Webアドレスからリンクされた画像の挿入

Webアドレスからリンクされた画像の挿入

Microsoft Excel の使用

Microsoft Excel(たとえば2007)で:

  1. 挿入メニューをクリックし、画像を選択します。

todo:image_alt_text

  1. 挿入画像ダイアログで画像のWebアドレスを指定します。

todo:image_alt_text

画像が挿入されます。

todo:image_alt_text

Aspose.Cells for Javaを使用する

Aspose.Cells for Javaは、ShapeCollection.addLinkedPicture(int upperLeftRow, int upperLeftColumn, int height, int width, java.lang.String sourceFullName)を使用してリンクされた画像を追加することをサポートしています。

このメソッドはPictureオブジェクトを返します。

次の例は、ワークシートにWebアドレスからリンクされた画像を追加する方法を示しています。

コードを実行した後、生成されたExcelファイルには、最初のワークシートにリンクされた画像が含まれます。

出力ファイル

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(InsertLinkedPicturefromWebAddress.class);
// Instantiate a new Workbook.
Workbook workbook = new Workbook();
// Insert a linked picture (from Web Address) to B2 Cell.
Picture pic = (Picture) workbook.getWorksheets().get(0).getShapes().addLinkedPicture(1, 1, 100, 100,
"http://www.aspose.com/Images/aspose-logo.jpg");
// Set the source of the inserted image.
pic.setSourceFullName("http://www.aspose.com/images/aspose-logo.gif");
// Set the height and width of the inserted image.
pic.setHeightInch(1.04);
pic.setWidthInch(2.6);
// Save the Excel file.
workbook.save(dataDir + "LinkedPicture.xlsx");