This is a migrated thread and some comments may be shown as answers.

export to excel dont show title columns

4 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eliud Puente
Top achievements
Rank 1
Eliud Puente asked on 18 Jun 2010, 06:08 PM
i have a radgrid
dynamic create columns, in function to dataset returned from db, this grid show ok but when i export to excel..   dont show column titles (column headers)
i asign values for  UniqueName, HeaderText, DataField  etc...
i export using this code..
        gdw.ExportSettings.FileName = "MyXlsFile"
        gdw.ExportSettings.OpenInNewWindow = True
        gdw.ExportSettings.IgnorePaging = True
        gdw.ExportSettings.HideStructureColumns = True
        gdw.ExportSettings.Excel.Format = GridExcelExportFormat.Html
        gdw.MasterTableView.ExportToExcel()


whats wrong.??

4 Answers, 1 is accepted

Sort by
0
Eliud Puente
Top achievements
Rank 1
answered on 18 Jun 2010, 06:23 PM
more info...
---code for add columns
        gdw.Columns.Clear()
        ' add columns  ..... numbers of columns and names... can change in runtime..
        Dim columna1 = New Object()
        For i = 0 To dtTable.Columns.Count - 1  ' columnas
       ' set columntype as need
            If dtTable.Columns(i).ColumnName <> "-" Then
                columna1 = New GridBoundColumn
            Else
                columna1 = New GridTemplateColumn
            End If
                gdw.MasterTableView.Columns.Add(columna1)
            columna1.HeaderStyle.HorizontalAlign = HorizontalAlign.Center

            If dtTable.Columns(i).ColumnName <> "-" Then
                columna1.UniqueName = dtTable.Columns(i).ColumnName
            Else
                columna1.UniqueName = "_" & i.ToString
            End If
            columna1.HeaderAbbr = dtTable.Columns(i).ColumnName
            columna1.HeaderTooltip = dtTable.Columns(i).ColumnName

            columna1.HeaderText = dtTable.Columns(i).ColumnName
            If dtTable.Columns(i).ColumnName <> "-" Then
                columna1.DataField = dtTable.Columns(i).ColumnName
            End If

            Select Case dtTable.Columns(i).ColumnName
                Case "f_negritas", "f_indentacion", "f_simbolo"
                    columna1.Visible = False
                Case "Concepto"
                    columna1.Visible = True
                    columna1.HeaderStyle.Width = 200
                    columna1.ItemStyle.HorizontalAlign = HorizontalAlign.Left
                Case "-", "-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9", "-10", "-11", "-12"
                    columna1.Visible = True
                    columna1.HeaderStyle.Width = 10
                    columna1.ItemStyle.HorizontalAlign = HorizontalAlign.Center
                    columna1.HeaderText = "-"
                Case Else
                    columna1.Visible = True
                    columna1.HeaderStyle.Width = 80
                    columna1.ItemStyle.HorizontalAlign = HorizontalAlign.Right
            End Select

        Next

        ' make datasource visible..
        gdw.Skin = "Web20"
        gdw.EnableAjaxSkinRendering = True
        gdw.Visible = True
        gdw.DataSource = dtTable
        gdw.DataBind()

0
Daniel
Telerik team
answered on 18 Jun 2010, 09:11 PM
Hello Eliud,

This usually happens when you are trying to export an invisible (Visible="false") RadGrid. Please make sure that the control is visible before exporting.

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Eliud Puente
Top achievements
Rank 1
answered on 19 Jun 2010, 12:32 AM
Hi Daniel..

as i show in second post..   Visible property  of  radgrid is set to true
when export to excel.. export all data  ...all except for  titles ......
column names as first row.. is required by user   : (        ...
i have a lot of examples that export ok.. but in this particular case...  not....

i have to do a workarround  for this issue ..   using a second grid only for export..
thanks a lot for support ..

....
        ' make datasource visible..
        gdw.Skin = "Web20"
        gdw.EnableAjaxSkinRendering = True
        gdw.Visible = True
        gdw.DataSource = dtTable
        gdw.DataBind()

0
Daniel
Telerik team
answered on 24 Jun 2010, 01:10 PM
Hello Eliud,

Invisible RadGrid is what causes this problem in 95% of the cases. Please modify your code so that your RadGrid is always visible and let me know how it goes.

If the problem still persists, post your code (or attach the files) so I can examine your approach.

Kind regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Eliud Puente
Top achievements
Rank 1
Answers by
Eliud Puente
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or