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

Exporting without BOM

2 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brendan Casey
Top achievements
Rank 1
Brendan Casey asked on 03 Jan 2011, 08:54 PM
Hello -

I have a RadGrid that I am using to present a custom reporting solution for our clients (they choose columns, column order, format, etc. then results are displayed in a RadGrid).

Everything is working great, except that when someone wants to save the file as a CSV, a "byte order marker" (BOM) appears at the beginning of the file.  This marker does not appear in the ExportOutput returned from GridExportingArgs that is fired in the OnGridExporting event.  The BOM is causing our customers to have to edit the file before they can run it through their automated systems.

My question is: How can I prevent the BOM from being saved into the CSV file?  Is this possible?

Thanks in advance,
-Brendan

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Jan 2011, 10:45 PM
Hello Brendan,

You can remove the BOM marker 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();
    }
}

I hope this helps.

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
Brendan Casey
Top achievements
Rank 1
answered on 04 Jan 2011, 03:20 PM
Daniel -

This worked perfectly.  Thanks!

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