Images in Cell

Posted by: john-shugart on 8 September 2017, 12:49 pm EST

  • Posted 8 September 2017, 12:49 pm EST

    I have taken the following example from the forums, but when it executes  the .Value line, I get the error "Object must implement IConvertible". I'm using version 2.5.2009.2005


    Dim icelltype As New FarPoint.Win.Spread.CellType.ImageCellType(FarPoint.Win.RenderStyle.Stretch)


    fpsMain.Sheets(iSheet).Cells(4, 4).CellType = icelltype


    Dim image As System.Drawing.Image = System.Drawing.Image.FromFile("Suez.bmp")


    fpsMain.Sheets(iSheet).Cells(4, 4).Value = image


    fpsMain.Sheets(iSheet).Cells(4, 4).ColumnSpan = 4


    fpsMain.Sheets(iSheet).Cells(4, 4).RowSpan = 4


     


    Any ideas what I need to do?


    Thanks in advance,


    John

  • Replied 8 September 2017, 12:49 pm EST

    John -

    I used basically the same code using 2.5.2011 and I do not receive the error...

    Dim img As New FarPoint.Win.Spread.CellType.ImageCellType(FarPoint.Win.RenderStyle.Stretch)
    FpSpread1.ActiveSheet.Cells(0, 0).CellType = img
    Dim image As System.Drawing.Image = System.Drawing.Image.FromFile("c:\clubfp.jpg")
    FpSpread1.ActiveSheet.Cells(0, 0).Value = image
    FpSpread1.ActiveSheet.Cells(0, 0).ColumnSpan = 4
    FpSpread1.ActiveSheet.Cells(0, 0).RowSpan = 4

    I noticed your Image.FromFile isn't really pointing to a file from a directory, but I wouldn't think that would throw the error you are seeing.  Any other info you can provide?  This is usually a database error.


  • Replied 8 September 2017, 12:49 pm EST

    Bob,


    It appears you are in fact correct. When I remove the .DataSource line, the problem goes away my Image displays just fine.


    This particular column doesn't have any data for this row and cell. Is there something I can do to place in where the DataSource doesn't interfere with it?


    Thanks in advance,


    John

  • Replied 8 September 2017, 12:49 pm EST

    John -

    Are you bound?  If so, then you can try setting AutoGenerateColumns to false and then set up your cell types.
  • Replied 8 September 2017, 12:49 pm EST

    Bob,


    All I do is set the DataSource property, then later, after I tried to set the celltype to image, I set the remaining cell types. There isn't alot of data on this particular sheet. But this error is just after I do set the DataSource.


    Any ideas???

  • Replied 8 September 2017, 12:49 pm EST

    If you are setting the image and then binding the spread then the cell will inherit whatever data type is in the field in the database and the image will not show up.  That's the only thing I can think of.
Need extra support?

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

Learn More

Forum Channels