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

Data type changes during export

6 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 01 Apr 2015, 08:40 PM
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.
    <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?

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Apr 2015, 11:55 AM
Hello Alex,

The problem with the header text can be solved by setting EnableSplitHeaderText property to false as shown below:
<MasterTableView EnableSplitHeaderText="false"  ...

For the second problem however I would need a simple runnable demo which I could debug on my side.

Best regards,
Daniel
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Alex
Top achievements
Rank 1
answered on 07 Apr 2015, 05:03 PM
Thanks for the response, Daniel.  That "EnableSplitHeaderText" change worked good.  I have added that to my personal Telerik tips/knowledge bank that I keep for future reference.  I created a demo as you requested but ran into a problem.  The "Attach files" in the forum will not allow me to attach my files because they are the wrong type (I tried to zip them to keep within the 2mb limit).  I am confused that it wants only ".gif, .jpg,", etc.  I know having a solution to run would be much easier than me copying all or some of my operational code and markup from my demo and inserting it in these blocks.  Do you have any other suggestions? 
0
Alex
Top achievements
Rank 1
answered on 08 Apr 2015, 02:41 PM
Thanks for the response, Daniel.  That "EnableSplitHeaderText" change worked good.  I have added that to my personal Telerik tips/knowledge bank that I keep for future reference.  I created a demo as you requested but ran into a problem.  The "Attach files" in the forum will not allow me to attach my files because they are the wrong type (I tried to zip them to keep within the 2mb limit).  I am confused that it wants only ".gif, .jpg,", etc.  I know having a solution to run would be much easier than me copying all or some of my operational code and markup from my demo and inserting it in these blocks.  Do you have any other suggestions? 
0
Daniel
Telerik team
answered on 09 Apr 2015, 11:55 AM
Hello Alex,

You can submit a ticket through our support system. Please add a reference to this forum post so that I can handle it faster.
Thanks in advance,
Daniel
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Alex
Top achievements
Rank 1
answered on 09 Apr 2015, 06:54 PM
Thanks for the response, Daniel.  That "EnableSplitHeaderText" change worked good.  I have added that to my personal Telerik tips/knowledge bank that I keep for future reference.  I created a demo as you requested but ran into a problem.  The "Attach files" in the forum will not allow me to attach my files because they are the wrong type (I tried to zip them to keep within the 2mb limit).  I am confused that it wants only ".gif, .jpg,", etc.  I know having a solution to run would be much easier than me copying all or some of my operational code and markup from my demo and inserting it in these blocks.  Do you have any other suggestions? 
0
Daniel
Telerik team
answered on 14 Apr 2015, 12:17 PM
Hello Alex,

Please examine the following blog post for more information on how to submit a support ticket:
How To Submit a Support Ticket

Looking forward to hearing from you.

Regards,
Daniel
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Alex
Top achievements
Rank 1
Share this question
or