Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > General Discussions > Excel Export Leading Zeros
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Excel Export Leading Zeros

Feed from this thread
  • John avatar

    Posted on May 20, 2011 (permalink)

    Is there an easy way to retain the leading zeros on cells when doing an export in excel?

    This demo page shows the problem:
    http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx

    If you do an export in word, the leading 0's on the ANATR and ANTON elements show up, however if you export those to excel,csv they are missing.

    Thanks

  • Posted on May 22, 2011 (permalink)

    Hello John,

    Check out the following forum which discussed the same.
    http://www.telerik.com/community/forums/aspnet-ajax/grid/export-as-string-not-int.aspx#963616

    Thanks,
    Shinu.

  • John avatar

    Posted on May 23, 2011 (permalink)

    Perfect, thank you!

  • Daniel Daniel admin's avatar

    Posted on May 26, 2011 (permalink)

    Hello John,

    You can find some examples in the online documentation:
    Word/Excel export (HTML-based)

    protected void RadGrid1_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e)
    {
        switch (e.FormattedColumn.UniqueName)
        {
            case "Column1":
                e.Cell.Style["mso-number-format"] = @"\@";
                break;
            case "Column2":
                e.Cell.Style["mso-number-format"] = @"$0.00";
                break;
            case "Column3":
                e.Cell.Style["mso-number-format"] = @"0000";
                break;
            case "Column4":
                e.Cell.Style["mso-number-format"] = @"mm\/dd\/yyyy";
                break;
        }
    }

    In fact you can set your own number format in the same way as you set the custom formats in Excel.

    Best regards,
    Daniel
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > General Discussions > Excel Export Leading Zeros