Hi, I am using win UltraGrid to export table in excel. when all the columns in grid are visible then its working perfectly ok but consider the following scenario
Image column index is 8 and 3,4,5,6,7 column are invisible then in this situation its not working. Column shows System.Drawing.Bitmap. it suppose to be display on 3 column but it displays on 8 column only.
Please help me ASAP
Yes, that's correct. I'm not sure exactly what version this functionality was added, but I'm sure it was later than 7.1. You will probably need to update to the latest version.
Hi Mike,
I need also export images of ultragrid to excel.But I have Infragistics 2007 vol. 1.Is this possible?(WorksheetImage is new in vol. 2 or 3... isn't?)Thanks very much,Juan Carlos Fidalgo FernándezStradivarius España, S.A. - Grupo Inditexjuancff@stradivarius.es
Thanks Mike
Okay, this is a problem with your code, then. You are getting the column by using:
int icolumn = e.GridRow.Cells.IndexOf("Result Icon");
This is wrong, because this will not account for invisible columns, it will just get the index of the column in the collection. You need the VisibleIndex on the grid column, I think. Try this, instead:
int icolumn = e.GridRow.Cells"Result Icon"].VisibleIndex;
I mean to say Total 8 column in the Datagrid. In that 3 are visible (1,2,8) rest are in hidden(3,4,5,6,7) in datagrid. And the 8th is the Image Column Now if I Export datagrid using Excel exporter And i used following code to export image in to Excel.
if (e.GridRow.Cells.Exists("Result Icon")) { int icolumn = e.GridRow.Cells.IndexOf("Result Icon"); // The values in this cell are byte arrays representing images. // In order to export them, we need to convert the byte array into an Image. // The EmbeddableImageRenderer on the column will do this for us. Image image = this.GetImageRendererImage(e.GridRow, e.GridRow.Band.Columns["Result Icon"]); // Create a WorksheetImage WorksheetImage worksheetImage = new WorksheetImage(image); // We will want to maintain the aspect ratio of the image so it looks the // same as it does in the grid cell. So determine the available size in the excel // worksheet. We do this by creating a region contain all three Excel cells, then // getting the bounds. WorksheetRegion worksheetRegion = new WorksheetRegion(e.CurrentWorksheet, e.CurrentRowIndex - 1, icolumn, e.CurrentRowIndex - 1, icolumn); Rectangle availableRect = worksheetRegion.GetBoundsInTwips(); // Set the bounds of the image. This method automatically fits the image into the // bounds and maintains the image aspect ratio. Note that the aspect ratio may be // slightly off due to some differences between the units used for width in // different versions of Excel. worksheetImage.SetBoundsInTwips(e.CurrentWorksheet, availableRect, true); // Add the image into the workbook e.CurrentWorksheet.Shapes.Add(worksheetImage); // Remove the text from the cell. e.CurrentWorksheet.Rows[e.CurrentRowIndex - 1].Cells[icolumn].Value = null; }
In this case Image is coming in excel sheet but its coming to wrong place. I hope now you got the problem.