开发者

How can i change excel cell value

i m exporting data from gridview to excel. This is my exported column:

POSTING KEY
1
50
50

but the column seems in the gridview like that:

POSTING KEY
01
50
50

Excel convert my string values to numeric when after export. But i must see "01". How can i change excel cell type or cell value in code wh开发者_StackOverflow社区en before save file.?


From Excel, highlight the column or the cell, right click and select "Format Cells", under the "Number" tab, click "Custom" under the Category:. In the Type: textbox, key in "00".


You can export text with a apostrophe suffix. for e.g. to display 01 instead of 1, you need to set cell's value as '01 and not just 01 Excel will take this value as text instead of number. But in this case you will see a Error SamrtTag in Excel saying "Number stored as Text" which can be turned off from preferences.


When you read or write a cell there are two values you can look at. The first one is value (e.g. cell.Value) which is the one you are probably setting. The second is NumberFormat (e.g. cell.NumberFormat). This is a string a will represent the format of the value when displayed in Excel, set this to an appropriate value (use the string representations in Excel if you're not sure which one you want).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜