ShapeCollection.AddLinkedPicture

ShapeCollection.AddLinkedPicture method

Add a linked picture.

public Picture AddLinkedPicture(int upperLeftRow, int upperLeftColumn, int height, int width, 
    string sourceFullName)
ParameterTypeDescription
upperLeftRowInt32Upper left row index.
upperLeftColumnInt32Upper left column index.
heightInt32The height of the shape. In unit of pixels
widthInt32The width of the shape. In unit of pixels
sourceFullNameStringThe path and name of the source file for the linked image

Return Value

Picture Picture object.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class ShapeCollectionMethodAddLinkedPictureWithInt32Int32Int32Int32StringDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Access the first worksheet
            Worksheet worksheet = workbook.Worksheets[0];
            
            // Add sample text to cell A1
            worksheet.Cells["A1"].PutValue("Image will be linked below:");
            
            // Add linked picture to the worksheet
            string imageUrl = "https://example.com/sample.jpg";
            worksheet.Shapes.AddLinkedPicture(1, 1, 100, 100, imageUrl);
            
            // Save the workbook
            workbook.Save("output_with_linked_picture.xlsx");
            
            Console.WriteLine("Workbook saved with linked picture.");
        }
    }
}

See Also