Skip to content

Exporting from vb.net as .csv with preserving leading zeros for numbers

vinoth kumar

Asked Feb 27, 2008, 7:49 PM EST1 answer
Share
LinkedInX

I am using vb.net and exporting data from grid which is in dataset and stored as  .CSV file format. It exports and stores in .CSV format. this is how it should work. And it is working.  When we open that exported file in notepad or other except (excel) it is correct. But when we open in excel then the leading zeros are eliminated. I want not to get eliminated.  And after exporting client is not ready to go and change settings manually. He wants that to be done in a single click of export button. (Zeros should not be eliminated in that exported file).He may open in excel or notepad or other.If he opens in notepad or other the other then it works fine with comma and zeros correctly.He wants in .CSV format with leading zeros if he opens in excel.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0

    I think this seems more like an excel issue than a c# issue.  I would post this in the microsoft excel forum.  One thing you could do is click on a column in excel and set it as Text, but not sure what would happen if you try to do this with importing a CSV file.   The other route you could go is to format the columns through COM as Text and then populate the data through COM rather than CSV.  I would check out

    http://www.excelforum.com

    0