I make from my program an excel file开发者_JS百科 (xls or csv).
I send 00123
and in Excel I see 123
How I can send and see 00123
Thanks in advance
Its because excel is treating the data as 'numeric'. A simple way to force Excel to accept anything as text is to prepend an apostrophe to the text.
e.g. to write an integer 123 as 00000123 just write:
ActiveCell = "'" & Format(123, "00000000")
EDIT: Another solution is to set the Cells NumberFormatProperty to text:
Worksheet.GetRange(..).EntireColumn.NumberFormat = "@"
You might want to see this article: Excel Cell Auto Format
In C# to see the CSV with the padding use
myVar.PadLeft(5,'0')
In Excel set the number format to custom 00000 or ZipCode
精彩评论