从Web地址插入链接图片

使用Microsoft Excel

在Microsoft Excel中(例如2007):

  1. 单击插入菜单,然后选择图片
  2. 在插入图片对话框中指定图片的Web地址。

使用 Aspose.Cells for .NET

Aspose.Cells for .NET 支持使用ShapeCollection.AddLinkedPicture(int upperLeftRow, int upperLeftColumn, int heightPixels, int widthPixels, string sourceFullName)添加链接图像。该方法返回一个Picture对象。

下面的示例显示了如何将来自Web地址的链接图片添加到工作表中。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a new Workbook.
Workbook workbook = new Workbook();
// Insert a linked picture (from Web Address) to B2 Cell.
Aspose.Cells.Drawing.Picture pic = workbook.Worksheets[0].Shapes.AddLinkedPicture(1, 1, 100, 100, "http:// Www.aspose.com/Images/aspose-logo.jpg");
// Set the height and width of the inserted image.
pic.HeightInch = 1.04;
pic.WidthInch = 2.6;
// Save the Excel file.
workbook.Save(dataDir+ "outLinkedPicture.out.xlsx");