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

[Solved] Csv Export contains nobr tags

1 Answer 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stoick
Top achievements
Rank 2
Stoick asked on 06 May 2009, 07:36 PM
I'm currently using the following to prevent the data in the grid from wrapping -


 Protected Sub RadGrid1_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles RadGrid1.ColumnCreated  
        'prevent grid details from wrapping  
        If (TypeOf e.Column Is Telerik.Web.UI.GridBoundColumn) Then  
            CType(e.Column, Telerik.Web.UI.GridBoundColumn).DataFormatString = "<nobr>{0}</nobr>" 
        End If  
    End Sub 

This works great until I try to export the grid using ExportToCSV().

 Protected Sub lnkBtnCSV_Click(ByVal sender As Object, ByVal e As System.EventArgs)  
        RadGrid1.ExportSettings.ExportOnlyData = True 
        RadGrid1.ExportSettings.IgnorePaging = True 
        RadGrid1.ExportSettings.OpenInNewWindow = True 
        RadGrid1.MasterTableView.ExportToCSV()  
    End Sub 


I get the "<nobr>1</nobr>" in the exported file. Is a way around this? The ExportToWord and ExportToExcel seem to already ignore the tags.

current output:
"CallID","CallNumber","CallType"  
"<nobr>1</nobr>","<nobr>1</nobr>","<nobr>Voice</nobr>"  
 
Want it to be this:  
"CallID","CallNumber","CallType"  
"1","1","Voice" 


1 Answer, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 11 May 2009, 01:01 PM
Hello Stoick,

The CSV export of the grid takes the string representation of the cell content (as opposed to Excel/Word/PDF export which operated with the rendered html) and that is the reason the nobr tags are part of the exported data.

To strip them you may consider using hidden columns which do not have DataFormatString set in this way and switch their visibility with their "twin" columns prior  to the call toe the ExportToCSV() method. See  this section of the documentation (paragraph 'Exporting GridButtonColumn/GridTemplateColumn/GridHyperLinkColumn data') for more info on this approach.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Stoick
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
Share this question
or