PictureCollection

PictureCollection

Overview

PictureCollection is a class in Aspose.Cells FOSS for .NET.

Represents collection of pictures anchored to a worksheet. Pictures allow embedding images directly into Excel worksheets from various sources. Supported image formats include JPEG, PNG, GIF, and BMP. Pictures can be loaded from files, streams, or byte arrays. Each picture can be independently positioned and sized using anchor coordinates. The collection provides methods to add, remove, and access pictures by index. var workbook = new Workbook(); var worksheet = workbook.Worksheets[0]; // Add pictures from different sources byte[] logoData = File.ReadAllBytes(“logo.png”); worksheet.Pictures.Add(2, 2, 5, 5, logoData); using (var stream = File.OpenRead(“image.jpg”)) { worksheet.Pictures.Add(10, 2, 15, 10, stream); } Console.WriteLine($“Added {worksheet.Pictures.Count} pictures”);

This class provides 2 methods for working with PictureCollection objects in .NET programs. Available methods include: Add, RemoveAt. All exported members are accessible to any .NET application after installing the Aspose.Cells FOSS for .NET package. Properties: Count.

Description

PictureCollection is a class in the Aspose.Cells FOSS library for .NET that exposes 4 methods and 1 property for programmatic use.

The class also provides the Count property (gets the count).

Properties

NameTypeAccessDescription
CountintReadGets the count.

Methods

SignatureDescription
Add(upperLeftRow: int, upperLeftColumn: int, lowerRightRow: int, lowerRightColumn: int, imageData: byte[])Adds a picture to the worksheet from raw image bytes and returns its index.
Add(upperLeftRow: int, upperLeftColumn: int, lowerRightRow: int, lowerRightColumn: int, stream: Stream)Adds a picture to the worksheet from raw image bytes and returns its index.
Add(upperLeftRow: int, upperLeftColumn: int, lowerRightRow: int, lowerRightColumn: int, fileName: string)Adds a picture to the worksheet from raw image bytes and returns its index.
RemoveAt(index: int)Removes the picture at the specified zero-based index.

See Also