Forum Home Login Register Search FAQ
Author Topic: Grid not export to Excel in Column order
Darren Gulliver Grid not export to Excel in Column order
on 2007-04-11 (EDT)

I'm using UltraGrid 2 and allowing the user to export the contents to Excel. 
However if the user moves the Columns the Excel shows the orginal column 
order let me explain.

Default Column order is 1 2 3 4

User changes to 1342 then exports to excel but the columns in Excel are 1234 
(data correct).

Here is my Code:

    iRow = 1
    iCol = 1
    With oWsh <--- Excel WorkSheet
        For iColumnIndex = 0 To grdGrid.Bands(0).Columns.Count - 1 <---Loop 
through the Columns                 
            If grdGrid.Bands(0).Columns(i).Hidden = False Then <-- Ignore if 
Column is Hidden
                Set oRge = oWsh.Cells(iRow, iCol)
                oRge.Value = grdGrid.Bands(0).Columns(iColumnIndex).Key <--- 
Column Name to excel
                oRge.Font.Bold = True
        Next iColumnIndex 
    End With

How can I output the Actual order they are on screen (1342 instead if 1234).


Message was originally posted to