James Cochrane
asked on
CSV file strips off leading 0 when reading in Excel.
I have an Excel spreadsheet that I save as a CSV file. There is one value that I save with a zero padding in the beginning of the field. When I load up the CSV file in Excel it strips off the leading 0. But if I look at it in notepad it is there. The problem I have is that when I try to read it in Excel Automation (using c#) it very much acts as it does when opening the file in Excel, i.e., stripping off the leading 0. The field is a key to a database table and will not work without the leading 0. Is there a way in Excel or preferrably C# to read the true value?
Thanks
Thanks
ASKER
I am using Excel to read the file.
>>I am using Excel to read the file.
Is the data generate4d in Excel? You can change the data to be '0001 in Excel to retain leading 0's.
Is the data generate4d in Excel? You can change the data to be '0001 in Excel to retain leading 0's.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Then it is there...
How are you reading it with C#? When I read files using VB it reads them with the leading 0. Or are you using an Excel object to open the file?
Look at the solution in the following link. It used the FSO to read thru a file a line at a time.
https://www.experts-exchange.com/questions/22455373/VB6-Remove-lines-with-comma-Text-manipulation.html