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

Exporting RadGrid to an ASCII CSV file

2 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 05 May 2011, 10:40 PM
We need to export the data from our RadGrids to just a plain ASCII CSV file for some customers, but the RadGrid "marks the file content as Unicode" (see http://www.telerik.com/help/aspnet-ajax/grid-csv-export.html).

Is there any way to turn off the Unicode marker and just get a plain ASCII file?

We are using the latest version of the components with source license.

Thanks,

Mark Bentley

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 May 2011, 12:05 PM
Hello Mark,

You can remove the BOM header this way:
protected void RadGrid1_GridExporting(object source, GridExportingArgs e)
{
    if (e.ExportType == ExportType.Csv)
    {
        Response.ContentType = "application/csv";
        Response.AddHeader("Content-Type", "text/csv");
        Response.BinaryWrite(new ASCIIEncoding().GetBytes(e.ExportOutput));
        Response.End();
    }
}

Let me know if you need further assistance.

Best regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Tony
Top achievements
Rank 1
answered on 06 May 2011, 02:21 PM
Thanks Daniel,

That worked great!
Tags
Grid
Asked by
Tony
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Tony
Top achievements
Rank 1
Share this question
or