GridWeb Display image in cell using ColumnDataType System.Byte

Hi

Does GridWeb display an image in a cell when it is bound to a DataView that contains a column of DataType "System.Byte"?

Thanks

Michael

Hi Michael,


Thank you for using Aspose.Cells.

Well, I don’t think there is any direct method of displaying the images contained in a column of DataView with type System.Byte. But you can do it manually by converting your image’s byte array data into stream and then adding the stream as a picture to a Cell. For example, please have a look at the following code. I suppose that the image byte data is at 4th column of each data row in the data table.

GridWeb1.WebWorksheets.Clear();

GridWeb1.WebWorksheets.Add();

GridWeb1.WebWorksheets.ActiveSheetIndex = 0;

foreach (var dr in data.Rows)

{

byte[] bytes = (Byte[])data.Rows[i][4];

MemoryStream memStream = new MemoryStream();

memStream.Write(bytes, 0, bytes.Length);

Aspose.Cells.GridWeb.Data.Picture pic = GridWeb1.WebWorksheets[0].Pictures.AddPicture(iRow,iCol);

pic.Image = System.Drawing.Image.FromStream( memStream);

iRow++;

}

Please feel free to contact us if you have any additional query. We will try to help you as soon as possible.

We also recommend you to download and use this latest version: Aspose.Cells for GridWeb v2.7.7.2006 in your applications.


Thanks for your reply. That solution works fine.

Hi,

Thanks for your feedback.

It’s good to know your issue is now resolved. If you encounter any other issue, please feel free to post, we will help you asap.

Also, you can now use the latest version: Aspose.Cells for GridWeb v2.7.8.2011 because we have fixed some of the page break issues relating to Chrome and FireFox inside it.