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

Leading Zero's - Export to Excel

3 Answers 654 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 08 Sep 2008, 01:26 PM
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?

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 09 Sep 2008, 05:18 AM
Hello Tony,

Wrap the cell contents with nbsp tags:

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

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

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tony
Top achievements
Rank 1
answered on 10 Sep 2008, 11:22 AM
Many Thanks Daniel - Thats just what the doctor ordered.

Tony
0
Peter Milchev
Telerik team
answered on 13 Jul 2018, 01:12 PM
Hello,

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:@}">

Regards,
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.
Tags
Grid
Asked by
Tony
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Tony
Top achievements
Rank 1
Peter Milchev
Telerik team
Share this question
or