Hello,
I have some ConditionalFormatRules for xamGrid (11.1) to add icons to cells. And I want to export this icons to Excel. So I get icon from
(row.Cells[i] as ConditionalFormattingCell).Control as ConditionalFormattingCellControl
and everything is ok. But if option xamGrid.GroupBySettings.GroupByOperation is set to GroupByOperation.GroupByRows then (row.Cells[i] as ConditionalFormattingCell).Control is null and I can't get icon from it.
I have been looking into your issue and would you please provide me with your sample application in order to investigate this behavior ?
Looking forward to hearing from you.
We use the following code to export icons to MS Excel
foreach (Column column in this.grid.Columns.AllVisibleChildColumns) { var conditionalFormattingCell = row.Cells[column] as ConditionalFormattingCell; if (conditionalFormattingCell != null) { ConditionalFormattingCellControl cellControl = conditionalFormattingCell.Control as ConditionalFormattingCellControl; if (cellControl != null && cellControl.Icon != null) { BitmapImage image = new BitmapImage(); image.CreateOptions = BitmapCreateOptions.None; image.UriSource = ((cellControl.Icon.LoadContent() as Image).Source as BitmapImage).UriSource; WriteableBitmap writeableBitmap = new WriteableBitmap(image); WorksheetShape worksheetShape = new WorksheetImage(writeableBitmap, new PngImageEncoder(), null); worksheetShape.PositioningMode = ShapePositioningMode.MoveWithCells; WorksheetCell cell = sheet.Rows[startRow].Cells[currentColumn + startColumn]; worksheetShape.TopLeftCornerCell = cell; worksheetShape.TopLeftCornerPosition = new Point(0.0F, 0.0F); worksheetShape.BottomRightCornerCell = cell; worksheetShape.BottomRightCornerPosition = new Point(33, 40); workSheet.Shapes.Add(worksheetShape); } } this.SetCellValue(sheet.Rows[startRow].Cells[currentColumn + startColumn], row.Cells[column] as Cell); currentColumn++; }
Hello Sergey,
Thank you for the provided code but it is not enough to reproduce your scenario. It seems that some methods and properties’ declarations are missing. Is there any reason because of which you are not able to attach your isolated sample application?
I have attached sample solution. Use "Load" button to load sample data and "Excel" to export it. The code working with exporting icon is placed to WriteDataRow function.
Would you please download our latest Service Release for NetAdvantage 11.1 because it seems that this issue is fixed there. You can download it from the following link from our website :
https://es.infragistics.com/Login.aspx?ReturnUrl=%2fMembership%2fDefault.aspx%3fpanel%3dDownloads&panel=Downloads
If this issue still appears, please attach an image file of the XamGrid before exporting to Excel.
I have been looking into this and when the icon is not visible, it doesn’t export. I can suggest looking through the following forum thread where Krasimir has provided an approach on how can export an image to Excel :
http://forums.infragistics.com/forums/p/57334/292534.aspx
If you have any other questions on this matter, feel free to ask.
I downloaded 2266 SR and it solved part of this problem. But if icon is not in visible area of grid, it doesn't export to Excel as it is null in CellControl.