C# Excel Interop: How to format cells to store values as text

前端 未结 3 1788
一生所求
一生所求 2021-02-07 04:05

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 digit

3条回答
  •  故里飘歌
    2021-02-07 04:45

    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.

提交回复
热议问题