Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numeric fields lose leading zero while writing CSV in c#

Tags:

c#

csv

I'm using an ASP.NET application which exports my clients data to CSV, I need my clients Phone number to be with the leading Zero. I need the phone numbers to be without "-" and without quotations, and due to the nature of my application I cannot use 3rd party products such as EPPLUS. I've tried to put a space and let the CSV "understand" that I need the phone number as text , but that doesn't seem right.

I would like to know how to make the excel include the leading zero , without using 3rd party products.

Thanks

like image 895
David Rasuli Avatar asked Aug 22 '12 11:08

David Rasuli


1 Answers

Change the data that is saved in the csv with the following format:

 ="00023423"

CSV example:

David,Sooo,="00023423",World

This will show 00023423 in excel and not 23423.

like image 102
Dror Avatar answered Oct 12 '22 23:10

Dror