Posted 24 August 2018, 3:41 am EST
Hi,
How can we export Flexgrid content to Excel with cell Images? I know SaveExcel does not support images but any workaround for this?
Forums Home / ComponentOne / WinForms Edition
Posted by: gokhan on 24 August 2018, 3:41 am EST
Posted 24 August 2018, 3:41 am EST
Hi,
How can we export Flexgrid content to Excel with cell Images? I know SaveExcel does not support images but any workaround for this?
Posted 24 August 2018, 7:54 am EST
Hi Gokhan!
I would like to inform you, now it is possible to export cell images from C1FlexGrid to Excel file using SaveExcel method. To use this feature, you need to have C1 build version 4.0.20173.286 or newer installed on your machine.
Attached is the sample application for your reference.
Otherwise, as its workaround, you can use C1Excel for the same purpose. Let me know if you need any further assistance.
Best regards,
Meenakshi
Posted 24 August 2018, 7:55 am EST
#Attached Sample
Posted 24 August 2018, 2:52 pm EST
Thanks for quick answer.
That’s good news!
One quick note on this, I found that if drawmode is set to OwnerDraw, It didn’t export images to Excel. If I set it to normal, than it worked for me. Not sure if its a bug or normal behavior.
Regards,
Gokhan
Posted 27 August 2018, 12:56 am EST
Hi Gokhan!
This is not a bug. Any image set in the cell acts as owner-drawn (using SetCellImage method of the grid). Therefore, while working with OwnerDraw mode, you need to handle this behaviour using e.Image property.
private void C1FlexGrid1_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
{
if(c1FlexGrid1.Cols[e.Col].DataType == System.Type.GetType("System.Drawing.Bitmap"))
{
e.Image = c1FlexGrid1.GetCellImage(e.Row, e.Col);
}
}
In case of any doubt, you can inform me.
Regards,
Meenakshi