I am using the 2014.2.724.40 version of the Telerik controls for ASP.NET AJAX. When I upgraded from a 2009 version the functionality in my export code in my web application appears to have changed creating problems. ( I did also upgrade the application from VS 2008 to VS 2010.) I have a user who takes the Excel spreadsheet of exported data and imports it into a MS Access db. The first thing she noticed was that the field names changed from having no spaces in the names to having spaces, which interrupted her import process. Next she noticed that the field data types were not matching either. Prior to the upgrade all this had worked satisfactorily. I have been able to replicate this myself and identified that date and Boolean fields are now coming across as short text data types.
This is a summary of the process: When the user selects "Export All Fields" and clicks the Export button (see attached screen print) the code calls a SP that retrieves about 80 fields of data from a SQL Server db. A hidden radgrid is then populated with these fields and data. Next, this data is then exported to an Excel spreadsheet. I think I have been able to determine that at least part of the 'problem' is in the population of the radgrid, as I have discovered in stepping through the code that the 'date fields' in the grid have a DataTypeName of System.String. Under MasterTableView I have set AutoGenerateColumns to True with no apparent positive result.
Below is my hidden radgrid first and then the export code.
Is there some other setting that will synchronize the columns to the SQL data types or would anyone have some other suggestion?
This is a summary of the process: When the user selects "Export All Fields" and clicks the Export button (see attached screen print) the code calls a SP that retrieves about 80 fields of data from a SQL Server db. A hidden radgrid is then populated with these fields and data. Next, this data is then exported to an Excel spreadsheet. I think I have been able to determine that at least part of the 'problem' is in the population of the radgrid, as I have discovered in stepping through the code that the 'date fields' in the grid have a DataTypeName of System.String. Under MasterTableView I have set AutoGenerateColumns to True with no apparent positive result.
Below is my hidden radgrid first and then the export code.
<
telerik:RadGrid
ID
=
"RadGridExport"
runat
=
"server"
Visible
=
"False"
>
<
ExportSettings
ExportOnlyData
=
"True"
IgnorePaging
=
"True"
Excel-Format
=
"Biff"
HideStructureColumns
=
"True"
>
<
Excel
Format
=
"Biff"
/>
</
ExportSettings
>
<
MasterTableView
ShowHeader
=
"False"
AutoGenerateColumns
=
"True"
>
<
RowIndicatorColumn
Visible
=
"False"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Created
=
"True"
>
</
ExpandCollapseColumn
>
</
MasterTableView
>
<
FilterMenu
EnableTheming
=
"True"
>
<
CollapseAnimation
Type
=
"OutQuint"
Duration
=
"200"
>
</
CollapseAnimation
>
</
FilterMenu
>
</
telerik:RadGrid
>
--------------------------
Public Sub ExportRadGrid(ByRef radGrid As Telerik.Web.UI.RadGrid)
'-- Export the specified grid to the specified format
radGrid.Visible = True
radGrid.Rebind()
With radGrid.ExportSettings
If radGrid.ID = "RadGrid1" Then
.FileName = "DivisionTotals"
ElseIf radGrid.ID = "RadGrid2" Then
.FileName = "GrantorTotals"
Else
.FileName = "GrantList"
End If
.ExportOnlyData = True
.IgnorePaging = True
.OpenInNewWindow = True
End With
Select Case ddlExportFormat.SelectedValue
Case "Microsoft Excel"
If radGrid.ID = "RadGrid1" Then
For Each col As GridColumn In radGrid.MasterTableView.RenderColumns
col.HeaderStyle.Width = Unit.Pixel(175)
Next
ElseIf radGrid.ID = "RadGrid2" Then
For Each col As GridColumn In radGrid.MasterTableView.RenderColumns
'For Each col1 As GridColumn In radGrid.
col.HeaderStyle.Width = Unit.Pixel(275)
Next
ElseIf radGrid.ID = "RadGridExport" Then 'RadGridGrants on Grants.aspx
Debug.Print("START")
radGrid.ShowHeader = False
radGrid.ExportSettings.SuppressColumnDataFormatStrings = False
For Each col As GridColumn In radGrid.MasterTableView.RenderColumns
Debug.Print("DataTypeName: " + col.DataTypeName)
Debug.Print("ColumnType: " + col.ColumnType)
Debug.Print("HeaderText: " + col.HeaderText)
Debug.Print("UniqueName: " + col.UniqueName)
col.HeaderText = col.UniqueName
'For Each col1 As GridColumn In radGrid.
col.HeaderStyle.Width = Unit.Pixel(275)
Next
Debug.Print("END")
End If
radGrid.MasterTableView.ExportToExcel()
Case "Microsoft Word"
radGrid.MasterTableView.ExportToWord()
Case "Adobe PDF"
radGrid.MasterTableView.ExportToPdf()
Case "CSV"
radGrid.MasterTableView.ExportToCSV()
End Select
End Sub
Is there some other setting that will synchronize the columns to the SQL data types or would anyone have some other suggestion?