Back to Devexpress

ImageInfo Interface

officefileapi-devexpress-dot-spreadsheet-8d16b16e.md

latest2.2 KB
Original Source

ImageInfo Interface

Exposes members used to specify information about an image placed in a cell.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public interface ImageInfo
vb
Public Interface ImageInfo

The following members return ImageInfo objects:

Example

The following code snippet places an image from a stream in a cell and specifies its alternative text:

csharp
using (Workbook workbook = new Workbook()) {
    Worksheet worksheet = workbook.Worksheets.ActiveWorksheet;

    byte[] imageBytes = File.ReadAllBytes("image.png");

    // Insert cell images from a stream
    worksheet.Cells["A2"].Value = imageStream;

    // Specify image information
    if (worksheet.Cells["A2"].Value.IsCellImage) {
        worksheet.Cells["A2"].ImageInfo.Decorative = true;
        worksheet.Cells["A2"].ImageInfo.AlternativeText = "Image AltText";
    }

    workbook.SaveDocument("result.xlsx");
}
vb
Using Optional ByVal workbook As New Workbook()
    Dim worksheet As Worksheet = workbook.Worksheets.ActiveWorksheet

    Dim imageBytes() As Byte = File.ReadAllBytes("image.png")

    ' Insert cell images from a stream
    worksheet.Cells("A2").Value = imageBytes()

    ' Specify image information
    If worksheet.Cells("A2").Value.IsCellImage Then
       worksheet.Cells("A2").ImageInfo.Decorative = True
       worksheet.Cells("A2").ImageInfo.AlternativeText = "Image AltText"
    End If

    workbook.SaveDocument("result.xlsx")
End Using

See Also

ImageInfo Members

DevExpress.Spreadsheet Namespace