Hi, I understand the ultraGridExcelExporter will export the grid as it appears on the screen...
Some columns on my grid use lookup tables (ValueLists), and I would like the export to export the actual value, not the text shown in the grid. Is there any option to make it happen?
Thank you
I like that! that should definitely work! Thanks Mike
That's an extremely complicated way of doing it. And you run the risk of losing any layout properties that were in your original grid that you now have to copy into the new grid. The Exporter already essentially does this for you. It doesn't create a whole new grid - but it clones the grid's DisplayLayout. It does this specifically so that you can modify the export layout without affecting the on-screen grid for situations exactly like this one. :)
Hi Tihomir,
I think using the cellExported event would work, but I've already implemented a different solution.
I created a new temporary grid, added my dataTable to it and exported it. I only need a dump of my dataTable...
Thank you for your reply
By default, the UltraGridExcelExporter exports the underlying cell values and then uses Excel's built-in dropdown-list functionality to translate the value into a display text, just like the grid does.
You are correct that turning off ExportValueLists will simply bypass this and export only the text the user sees.
Teodora's solution is okay and should work. But there's a simpler way.
What you could do is handle the ExportStarted event. This event passes you an UltraGridLayout variable in the event args. This is a cloned copy of the grid's DisplayLayout. So you could access this layout, get the band, get the column and remove the ValueList from the column (set it to null). This would essentially remove the ValueList from the export layout without affecting the on-screen grid.
Hey Monica,
In case you want to export the ID of the object(its a bit confusing so I'm sorry if I am not getting it right), you can hook to the cellExported event of the ultraGridExcelExporter and place reverse logic based on the value of the cell.
It will look similar to this:
private void ultraGridExcelExporter1_CellExported(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.CellExportedEventArgs e) { if (e.GridColumn.Key == "valueListColumn") { string cellValue = (string)e.GridRow.GetCellValue(e.GridColumn); // get object by property name from the valuelist WorksheetRow worksheetRow = e.CurrentWorksheet.Rows[e.CurrentRowIndex]; WorksheetCell worksheetCell = worksheetRow.Cells[e.CurrentColumnIndex]; worksheetCell.value = valueToBeExported; } }
Please let me know if this doesn't work.
Sincerely,Tihomir TonevAssociate Software DeveloperInfragistics