Spread Windows Forms 16
Spread Windows Forms 16.0 Product Documentation / Developer's Guide / Cells / Adding Image in a Cell
In This Topic
    Adding Image in a Cell
    In This Topic

    Spread for Winforms provides the ability to insert images in a cell as a value. This helps to add images in a cell without converting the cell into a ImageCellType class object.

    To add images using ImageCellType, refer to Setting an Image Cell topic.

    You can use one of the following methods to display images in a cell. These methods help to set the image object to the cell value, set a local image file path, or set a base64-encoded image string in cells:

    Note: The data type return by string only supports local image file path.

    Display Image and Cell Value

    If you want to display the image along with a cell value, it can be achieved by using the CellImageAttribute class members. Its constructor method takes the following parameters:

    Parameter Description

    A string value indicating the member specified cell inline image data.


    A Boolean value indicating whether the member is a field. Default is false.

    The following GIF illustrates an image displayed along with a cell value according to the image attributes set in Spread.

    Copy Code
    private void CellImageAndValue_Load(object sender, EventArgs e)
        IWorksheet TestActiveSheet = fpSpread1.AsWorkbook().ActiveSheet;
        fpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.CalcFeatures = CalcFeatures.All;
        fpSpread1.LegacyBehaviors = FarPoint.Win.Spread.LegacyBehaviors.None;
        // Displaying both image and cell value
        RichValue<Country> ct = new RichValue<Country>(new Country()
            Name = "Apple",
        ct.ShowDetailsIcon = true;
        TestActiveSheet.Cells["A1"].Value = ct;
        TestActiveSheet.Rows[0].RowHeight = 100;
        TestActiveSheet.Columns[0].ColumnWidth = 150;
        TestActiveSheet.Columns[2].ColumnWidth = 100;
    public class Country
        public string Name { get; set; }
        public string Image
                return @"D:\apple.jpg";
    Visual Basic
    Copy Code
    Private Sub CellImageAndValue_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim TestActiveSheet As IWorksheet = FpSpread1.AsWorkbook().ActiveSheet
        FpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.CalcFeatures = CalcFeatures.All
        FpSpread1.LegacyBehaviors = FarPoint.Win.Spread.LegacyBehaviors.None
        'Displaying both image and cell value
        Dim ct As RichValue(Of Country) = New RichValue(Of Country)(New Country() With {
            .Name = "Apple"
        ct.ShowDetailsIcon = True
        TestActiveSheet.Cells("A1").Value = ct
        TestActiveSheet.Rows(0).RowHeight = 100
        TestActiveSheet.Columns(0).ColumnWidth = 150
        TestActiveSheet.Columns(2).ColumnWidth = 100
    End Sub
    Public Class Country
        Public Property Name As String
        Public ReadOnly Property Image As String
                Return "D:\apple.jpg"
            End Get
        End Property
    End Class

    Note: This class has a higher priority than CellValueDataTypeAttribute class.

    Spread for WinForms also provides the GC.IMAGE function to place an image in a cell. For more information about this function, refer to the Image Sparkline topic. You can also use the IMAGE function, which inserts images into cells from a source location.