Insert a Linked Picture from Web Address
Contents
[
Hide
]
Sometimes you need to insert a picture from the web (http://) into a worksheet. To do so, specify the picture’s URL and the picture will be downloaded every time the spreadsheet is opened in Microsoft Excel. The image is not physically embedded into the Excel document, but points to a web resource.
Using Microsoft Excel
In Microsoft Excel (for example 2007):
- Click the Insert menu and select Picture.
- Specify the web address for the picture in the Insert Picture dialog.
Using Aspose.Cells for .NET
Aspose.Cells for .NET supports adding a linked image using the ShapeCollection.AddLinkedPicture(int upperLeftRow, int upperLeftColumn, int heightPixels, int widthPixels, string sourceFullName). The method returns a Picture object.
The following example shows how to add linked picture from web address to a worksheet.
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-.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"); |