Iam Exporting my datas to .csv format from asp.net project. When iam exporting those numbers having zero at beginning was handled by adding
Then it is visible as 0183 in excel. But the problem is when i am copying these things to other files it again copied as ="0183"
So , can anyone help me to handle zero started numbers in export to .csv from C# coding?
Best How To :
The problem is that its the excel thats auto converting the csv to string. If you create a simple CSV and open it in excel using the Open with Excel you can see the behavior. So first and easier option will be making the column type
text and viewing it.
The other option will be to parse the column using regex before re-translating it to another format like this.
var inputString = "=\"0813\"";
var match = Regex.Match(inputString, "=\"([^\"]*)\"");
var output = match.Groups.Count > 1 ? match.Groups.Value : inputString;