Leading Zeros Are Truncated While Exporting Csv To Excel

venu1234

New member
Joined
Sep 11, 2013
Messages
1
Programming Experience
5-10
Hi,
I need to open up a csv into excel using vb.net. I am using the below code to achieve that.
xlsApp = New Excel.ApplicationClass

xlsApp.Visible = True

xlsWB = xlsApp.Workbooks.Open("C:\test1.xls")

But my problem is when opened in excel, leading zeroes are truncated in the cells.
for example 002 is showing up as 2
Can anybody help me on this please.

Is there any other way to open csv file in excel without truncating leading zeros?
Thanks in advance.
 
I'm not sure if there's a better option in newer versions but, if not, the way to force Excel to interpret data as text is to prefix it with a single quote. In that case your 002 would be interpreted as a literal string and not be truncated rather being interpreted as the number 2 and displayed as such.
 
Back
Top