Hi -
I have a dataset bound to an ultrawingrid. One of the column [Status] is assigned a ValueList which contains only two values - Approved or UnApproved. Depending on the value for each row, I display an Image in the Status column cell for that particular row. and I am using the following code
statusList.DisplayStyle = ValueListDisplayStyle.Picture; e.Layout.Bands[0].Columns["MapStatus"].ValueList = statusList; e.Layout.Bands[0].Columns["MapStatus"].CellActivation = Activation.NoEdit;
where statusList is my ValueList.
Now when I export the rows to excel,I am expecting the actual value [ie either Approved/UnApproved] to be exported to excel, which is not happening.The column is empty when exported. Is there something that I am missing here or how do we accomplish this..?
Thanks
Rajesh
Hi Rajesh,
What version of the controls are you using?
What are the contents of the ValueList? Are you populating the list with items that have both a DataValue and DisplayText?
Thanks for your time Mike
The version is 9.2
Following is the code that I have in the Initializelayout event of the Grid
// Create a ValueList with an image for each item. ValueList statusList = e.Layout.ValueLists.Add("Status");
ValueListItem vli = statusList.ValueListItems.Add("Approved");vli.Appearance.Image = XYZ.Resources.Approve;
vli = statusList.ValueListItems.Add("UnApproved");vli.Appearance.Image = XYZ.Resources.Denied;// Set the DisplayStyle to Picture so that the list displays only pictures, and no textstatusList.DisplayStyle = ValueListDisplayStyle.Picture;// Assign the ValueList to the column and disable Edite.Layout.Bands[0].Columns["MapStatus"].ValueList = statusList;e.Layout.Bands[0].Columns["MapStatus"].CellActivation = Activation.NoEdit;
And then I bind the dataset which contains a column named 'MapStatus'. I have added the Approved and Denied icons to the resource file and I set them to the valuelistitem as seen in the code above.Depending on the value [Approved/UnApproved] in the dataset, I am able to see the corresponding image displayed in the cell for the Status Column.But when I export the row, this data is missing.I am not sure whether the images get exported , but at the least the expectation is that the actual cell value [ie Approved/Unapproved] gets exported .
We had a holiday weekend here in the United States, so I didn't get to look a this until now. :)
I tried this out and I get the same results. The cells in Excel are completely blank. It looks like the UltraGridExceptExporter simply does not handle the images from the ValueList.
I am going to forward this thread over to Infragistics Developer Support so they can write it up and have it looked into. But unfortunately, version 9.2 is retired. So even if this is fixed, it will only be fixed in the latest supported versions.
You can probably work around this using the UltraGridExcelExporter's CellExported event. You can trap for the particular column you want and then write the image directly into the Excel cell based on the grid cell's Value.
private void ultraGridExcelExporter1_CellExported(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.CellExportedEventArgs e) { if (e.GridColumn.Key == "MapStatus") { string cellValue = (string)e.GridRow.GetCellValue(e.GridColumn); Image image = null; if (string.Compare(cellValue, "Approved") == 0) image = XYZ.Resources.Approve; else image = XYZ.Resources.Denied; WorksheetRow worksheetRow = e.CurrentWorksheet.Rows[e.CurrentRowIndex]; WorksheetCell worksheetCell = worksheetRow.Cells[e.CurrentColumnIndex]; WorksheetImage worksheetImage = new WorksheetImage(image); Rectangle rect = worksheetCell.GetBoundsInTwips(); worksheetImage.SetBoundsInTwips(e.CurrentWorksheet, rect, true); e.CurrentWorksheet.Shapes.Add(worksheetImage); } }
HI MIke
I am continuing this work, after export to excel the image is displayed in the excel sheet, problem is i am not able to Filter the rows based on the MapStaus Image column, as images will not come in the FIlters,please help me to solve this.
Hi,
I'm a little confused. Why can't you filter?
The code I posted here is going to essentially cover up the cell with an image. But the value was already written into that cell. So Excel should allow you to filter - it will just show the strings on the filter dropdown list instead of the image. There' no way around that as far as I know.