Radgrid excel export : <BR> to new line

Thread is closed for posting
4 posts, 1 answers
  1. Prabeesh
    Prabeesh avatar
    3 posts
    Member since:
    Nov 2012

    Posted 14 Nov 2012 Link to this post

    I am facing an issue with Radgrid while exporting to excel. The <BR> tag not creating a new line in the excel instead it take it as a BR text. Please help
  2. Answer
    Kostadin avatar
    1733 posts

    Posted 19 Nov 2012 Link to this post

    Hi Prabeesh,

    Could you specify which export method you are using? If you are using ExcelML then instead <br> tag you should use "&#10", because that is the code for the new row. The following code snippet demonstrates how you could replace the <br> tags into the excel document.
    protected void RadGrid1_GridExporting(object source, GridExportingArgs e)
        e.ExportOutput = e.ExportOutput.Replace("&lt;br /&gt;", "&#10;");

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Prabeesh
    Prabeesh avatar
    3 posts
    Member since:
    Nov 2012

    Posted 26 Dec 2012 Link to this post

    Thank You.
    Above solution worked but along with the word wrap style.
    Add style in ExcelMLExportStylesCreated
         Telerik.Web.UI.GridExcelBuilder.StyleElement StyleElement = new Telerik.Web.UI.GridExcelBuilder.StyleElement();
                StyleElement.Id = "brstyle";
                StyleElement.AlignmentElement.Attributes["ss:WrapText"] = "1";

    and apply it for the cell in the ExcelMLExportRowCreated event

      CellElement cElement = e.Row.Cells.GetCellByName("Total Sales");
                    cElement.StyleValue = "wstyle";
  4. Support
    Support avatar
    5 posts
    Member since:
    Feb 2007

    Posted 01 May 2014 Link to this post

    If your using the Biff Excel format to avoid the Excel error on opening the Excel file, you can use this solution.  Add OnBiffExporting="grid_OnBiffExporting" client side and the method below server side.

    protected void grid_OnBiffExporting( object sender, GridBiffExportingEventArgs e )
       foreach ( Cell cell in e.ExportStructure.Tables[ 0 ].Cells ) {
          cell.Value = cell.Text.Replace( HTML_BREAK_ROW, string.Empty );

    private const string HTML_BREAK_ROW = "<BR>";
Back to Top