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
Hi,
I'm afraid I do not understand what you are describing. The visibility of other columns certainly should not affect whether an image shows up or not. But I am pretty sure that the Excel Exporter does not support exporting images like this from the grid, anyway.
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.