Reputation: 163
I'm exporting the values in the grid to excel through C# code. When i open the exported excel, the string column is displayed as integer and the leading '0' in that field gets deleted. how to handle this.
Upvotes: 0
Views: 445
Reputation: 26766
A quick way to get around this is to prefix your cell value with an apostrophe.
Excel hides the apostrophe automatically and forces the text mode for the cell to Text
Try it directly in Excel and you'll see what I mean eg type '07799123477
into a cell with General
text formatting (the default)
Upvotes: 0
Reputation: 4564
I have no experience in making Excel files but when entering text in Excel you can write '00123. The ' makes the whole difference.
Upvotes: 0
Reputation: 43097
This isn't a programming issue; it's Excel's default way of displaying what it thinks are numbers.
It assumes that 00001
is a number and should be displayed as 1
. Change your cells to display "Text" instead of numbers in Excel.
Upvotes: 1