ShapeCollection.AddPicture

AddPicture(int, int, int, int, Stream)

Adds a picture to the collection.

public Picture AddPicture(int upperLeftRow, int upperLeftColumn, int lowerRightRow, 
    int lowerRightColumn, Stream stream)
ParameterTypeDescription
upperLeftRowInt32Upper left row index.
upperLeftColumnInt32Upper left column index.
lowerRightRowInt32Lower right row index
lowerRightColumnInt32Lower right column index
streamStreamStream object which contains the image data.

Return Value

Picture Picture object.

Examples

using System;
using System.IO;
using Aspose.Cells;
using Aspose.Cells.Drawing;

namespace AsposeCellsExamples
{
    public class ShapeCollectionMethodAddPictureWithInt32Int32Int32Int32StreamDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Get the shapes collection
            ShapeCollection shapes = worksheet.Shapes;

            // Add a picture from a file stream
            using (FileStream fs = new FileStream("image.jpg", FileMode.Open))
            {
                Picture picture = shapes.AddPicture(1, 0, 1, 0, fs);
            }

            // Save the workbook
            workbook.Save("output.xlsx");
        }
    }
}

See Also


AddPicture(int, int, Stream, int, int)

Adds a picture to the collection.

public Picture AddPicture(int upperLeftRow, int upperLeftColumn, Stream stream, int widthScale, 
    int heightScale)
ParameterTypeDescription
upperLeftRowInt32Upper left row index.
upperLeftColumnInt32Upper left column index.
streamStreamStream object which contains the image data.
widthScaleInt32Scale of image width, a percentage.
heightScaleInt32Scale of image height, a percentage.

Return Value

Picture Picture object.

Examples


[C#]
//add a picture
using (FileStream fs = new FileStream("image.jpg", FileMode.Open))
{
    Picture picture = shapes.AddPicture(1, 1, fs, 50, 60);
}

See Also