I'm able to connect to and read an excel file no problem. But when importing data such as zipcodes that have leading zeros, how do you prevent excel from guessing the datatype and in the process stripping out leading zeros?
How do you prevent leading zeros from being stripped when importing an excel doc using c#
Add "\t" before your string. It'll make the string seem in a new tab.
'=" 00022556"' from Sql server is excellent way to handle leading zero problem
Saving the file as a tab delimited text file has also worked well.
---old Unfortunately, we can't rely on the columns of the excel doc to stay in a particular format as the users will be pasting data into it regularly. I don't want the app to crash if we're relying on a certain datatype for a column.
prefixing with ' would work, is there a reasonable way to do that programatically once the data already exists in the excel doc?