Leading Zero's - Export to Excel

4 posts, 0 answers
  1. Tony
    Tony avatar
    8 posts
    Member since:
    Jul 2008

    Posted 08 Sep 2008 Link to this post

    Hi I need to export data via the radgrid to excel - problem is the key field is a ten digit number which the first six is the patient date of birth ...

    Problem is when excel opens with the export the leading zero is missing therefore no longer the patient number

    example before export - number 0101071111 
                            after export - number 101071111

    Any ideas?
  2. Daniel
    Daniel avatar
    4949 posts

    Posted 09 Sep 2008 Link to this post

    Hello Tony,

    Wrap the cell contents with nbsp tags:

    foreach (GridTableCell gcell in e.Item.Cells) 
        gcell.Text = String.Format(" {0}", gcell.Text); 

    <telerik:GridBoundColumn DataFormatString="&nbsp;{0}" DataField="Id"></telerik:GridBoundColumn> 

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Tony
    Tony avatar
    8 posts
    Member since:
    Jul 2008

    Posted 10 Sep 2008 Link to this post

    Many Thanks Daniel - Thats just what the doctor ordered.

  4. Peter Milchev
    Peter Milchev avatar
    912 posts

    Posted 13 Jul 2018 Link to this post


    We are sharing another possible approach and also attaching a sample project implementing it. 

    The column format can be specified by setting the DataFormatString property to {0:@}, where the @ sign will indicate that the value is of type text.

    <telerik:GridBoundColumn UniqueName="InvNo" DataField="InvNo" HeaderText="Inv No." ShowFilterIcon="false" AllowFiltering="false" AutoPostBackOnFilter="true" DataFormatString="{0:@}">

    Peter Milchev
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top