I'm writing numbers to an Excel spreadsheet from a DataTable
and all of these numbers are 5 digits long with preceding 0s if the number itself is less than 5 digits long (so 395 would be stored as 00395, for example).
When entering these numbers into Excel (using C#), it's storing them as numbers and eliminating the preceding 0s. Is there any way I can format the cells from C# in order to get the values to be stored as text rather than numbers?
You can SomeRange.NumberFormat = "@";
or if you prefix the value with a '
and write it to the cell excel will treat it as a number-stored-as-text and provide a visual cue.