Images in Cell

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

  • Posted 8 September 2017, 12:49 pm EST

    <P>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</P><FONT color=#0000ff size=2>
    <P>Dim</FONT><FONT size=2> icelltype </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> FarPoint.Win.Spread.CellType.ImageCellType(FarPoint.Win.RenderStyle.Stretch)</P>
    <P>fpsMain.Sheets(iSheet).Cells(4, 4).CellType = icelltype</P>
    <P></FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> image </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> System.Drawing.Image = System.Drawing.Image.FromFile(</FONT><FONT color=#a31515 size=2>"Suez.bmp"</FONT><FONT size=2>)</P>
    <P>fpsMain.Sheets(iSheet).Cells(4, 4).Value = image</P>
    <P>fpsMain.Sheets(iSheet).Cells(4, 4).ColumnSpan = 4</P>
    <P>fpsMain.Sheets(iSheet).Cells(4, 4).RowSpan = 4</P>
    <P> </P>
    <P>Any ideas what I need to do?</P>
    <P>Thanks in advance,</P>
  • Replied 8 September 2017, 12:49 pm EST

    John -<br><br>I used basically the same code using 2.5.2011 and I do not receive the error...<br><br>Dim img As New FarPoint.Win.Spread.CellType.ImageCellType(FarPoint.Win.RenderStyle.Stretch)<br>FpSpread1.ActiveSheet.Cells(0, 0).CellType = img<br>Dim image As System.Drawing.Image = System.Drawing.Image.FromFile("c:\clubfp.jpg")<br>FpSpread1.ActiveSheet.Cells(0, 0).Value = image<br>FpSpread1.ActiveSheet.Cells(0, 0).ColumnSpan = 4<br>FpSpread1.ActiveSheet.Cells(0, 0).RowSpan = 4<br><br>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. <br><br><br>
  • Replied 8 September 2017, 12:49 pm EST

    <P>It appears you are in fact correct. When I remove the .DataSource line, the problem goes away my Image displays just fine.</P>
    <P>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?</P>
    <P>Thanks in advance,</P>
  • Replied 8 September 2017, 12:49 pm EST

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

    <P>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.</P>
    <P>Any ideas???</P>
  • 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.<br>
Need extra support?

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

Learn More

Forum Channels