Simple Image in a cell.

Posted by: hpadmasola1 on 8 September 2017, 2:08 pm EST

  • Posted 8 September 2017, 2:08 pm EST

    Iam having difficulty to show a simple image in a cell. Iam using the following code. I added a jpg file to my visual studio 2008 windows application. Then I tried the code below. Any pointers will be greatly appreciated.



          Dim img As FarPoint.Win.Spread.CellType.ImageCellType = New FarPoint.Win.Spread.CellType.ImageCellType(FarPoint.Win.RenderStyle.Stretch)
            FPSpread1.ActiveSheet.Cells(0, 0).Locked = True
            FPSpread1.ActiveSheet.Cells(0, 0).CellType = img
            Dim s As System.IO.Stream
            s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyApplication.StopSign.jpg")
            If (s IsNot Nothing) Then
                FPSpread1.ActiveSheet.Cells(0, 0).Value = New Bitmap(s)
            End If 

  • Replied 8 September 2017, 2:08 pm EST

    ok.. I tried something different using Imagelist control. I used the below code but iam getting this error now.

    "Object must implement iconvertible"

    <FONT color=#0000ff size=2><FONT color=#0000ff size=2>

    Dim</FONT></FONT><FONT size=2> img </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> FarPoint.Win.Spread.CellType.ImageCellType = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> FarPoint.Win.Spread.CellType.ImageCellType(FarPoint.Win.RenderStyle.Normal)

    </FONT><FONT size=2>

    FPSpread1.ActiveSheet.Cells(0, 0).CellType = img

    FPSpread1.ActiveSheet.Cells(0, 0).Value = MainFrm.ImageList1.Images(0)

    </FONT> Any help is appreciated.



  • Replied 8 September 2017, 2:08 pm EST


    In case you wish to add an image to the cell type, this can be easily done either by specifying the location of the image file or using the ResourceManager. I will illustrate the usage of both:


    FpSpread1.Sheets(0).Cells(1, 1).CellType = New FarPoint.Win.Spread.CellType.ImageCellType
    FpSpread1.Sheets(0).Cells(1, 1).Value = New Bitmap("c:\test.bmp")


    The above will load the image in cell(0,0) from the C: drive of your machine.You can also add desired image in the Resource file (Resx) and then load it from the ResourceManager. Add a Resource file to your project, to this file add the image file in my case I used Face.jpg. Below snippet will load the image from the resource file to Cell(0,0).


            Dim img As New FarPoint.Win.Spread.CellType.ImageCellType
            FpSpread1.ActiveSheet.Cells(0, 0).CellType = img
            FpSpread1.ActiveSheet.Cells(0, 0).Value = New Bitmap(My.Resources.Resource1.FACE)


    Hope this helps. Thanks

  • Replied 8 September 2017, 2:08 pm EST

    I finally figured it out. The  error "Object must implement iconvertible" was coming up because I was trying to put a null in the column that was of imagecelltype.

    Thanks Suresh for your help!


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels