I'm using 20.1. I have a report which requires different numeric formats in the same column. For example, one row is "percent of sales", which obviously needs to be formatted as percent, while other rows are formatted as currency.
After a lengthy search, I found that the only way to do this was to leave the columns unformatted, and apply an EditorWithText to the specific cells in InitializeRow, despite the fact that this is a read-only report.
(As an aside, I can't understand why it's possible to apply different CellAppearances in a single column, but not different numeric formats.)In any case, the EditorWithText workaround worked. But when I export the grid to Excel, there's no numeric formatting at all, because the export works on a column-by-column basis.
I'm already using ultraGridExcelExporter1_InitializeColumn to convert Ultragrid formats to Excel formats, and I'm using ultraGridExcelExporter1_ExportEnding to go into exported reports and autofit columns, since the exporter doesn't do that natively. I'm happy to go into the the reports and apply formatting myself on a cell-by-cell basis, since the reports aren't very big. But I can't do that, because I have no way to loop through grid columns in their display order. The columns collection is in datasource order, which in my case *can't* be the same as display order.
Is there any way for me to loop through columns in the order in which they appear, visually, in the report? Preferably non-hidden columns only, but I can allow for that myself if need be.
Wow. In a billion years, I would never have come up with that on my own. Thank you so much.
Hello Lisa,
If you need to loop through only the visible columns, you can use the GetFirstVisibleCol method and provide the ActiveColScrollRegion, which would provide the first visible column. After that a while loop could be used to apply the logic needed to format that column and lastly the column should be assigned to the next visible column by using the GetRelatedVisibleColumn by providing VisibleRelation.Next. The code for this should be similar to the code below:
UltraGrid grid = this.ultraGrid1; UltraGridBand band = grid.DisplayLayout.Bands[0]; UltraGridColumn column = band.GetFirstVisibleCol(grid.ActiveColScrollRegion, true); while (column != null) { //apply your logic here column = column.GetRelatedVisibleColumn(VisibleRelation.Next); }
Please let me know if you have any questions.
Regards, Ivan Kitanov