PictureCollection.Add

Add(int, int, int, int, Stream)

Adds a picture to the collection.

public int Add(int topRow, int leftColumn, int bottomRow, int rightColumn, Stream stream)
ParameterTypeDescription
topRowInt32Upper left row index.
leftColumnInt32Upper left column index.
bottomRowInt32Lower right row index
rightColumnInt32Lower right column index
streamStreamStream object which contains the image data.

Return Value

Picture object index.

Examples

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

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

            // Add a picture from stream
            using (FileStream fs = new FileStream("image.jpg", FileMode.Open))
            {
                worksheet.Pictures.Add(10, 10, 200, 200, fs);
            }

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

See Also


Add(int, int, int, int, string)

Adds a picture to the collection.

public int Add(int topRow, int leftColumn, int bottomRow, int rightColumn, string fileName)
ParameterTypeDescription
topRowInt32Upper left row index.
leftColumnInt32Upper left column index.
bottomRowInt32Lower right row index
rightColumnInt32Lower right column index
fileNameStringImage filename.

Return Value

Picture object index.

Examples

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

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

            PictureCollection pictures = worksheet.Pictures;
            pictures.Add(1, 1, 5, 5, "image.jpg");

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

See Also


Add(int, int, Stream)

Adds a picture to the collection.

public int Add(int topRow, int leftColumn, Stream stream)
ParameterTypeDescription
topRowInt32Upper left row index.
leftColumnInt32Upper left column index.
streamStreamStream object which contains the image data.

Return Value

Picture object index.

Examples

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

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

            // Add a picture from stream
            using (FileStream fs = new FileStream("image.jpg", FileMode.Open))
            {
                worksheet.Pictures.Add(1, 1, fs);
            }

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

See Also


Add(int, int, string)

Adds a picture to the collection.

public int Add(int topRow, int leftColumn, string fileName)
ParameterTypeDescription
topRowInt32Upper left row index.
leftColumnInt32Upper left column index.
fileNameStringImage filename.

Return Value

Picture object index.

Examples

using System;
using Aspose.Cells;

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

            Aspose.Cells.Drawing.PictureCollection pictures = worksheet.Pictures;
            pictures.Add(1, 1, "image.jpg");

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

See Also


Add(int, int, Stream, int, int)

Adds a picture to the collection.

public int Add(int topRow, int leftColumn, Stream stream, int widthScale, int heightScale)
ParameterTypeDescription
topRowInt32Upper left row index.
leftColumnInt32Upper 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 object index.

Examples


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

See Also


Add(int, int, string, int, int)

Adds a picture to the collection.

public int Add(int topRow, int leftColumn, string fileName, int widthScale, int heightScale)
ParameterTypeDescription
topRowInt32Upper left row index.
leftColumnInt32Upper left column index.
fileNameStringImage filename.
widthScaleInt32Scale of image width, a percentage.
heightScaleInt32Scale of image height, a percentage.

Return Value

Picture object index.

Examples

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

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

            PictureCollection pictures = worksheet.Pictures;
            pictures.Add(1, 1, "image.jpg", 50, 50);

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

See Also