从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");