问题描述
我在从C#.Net 2.0应用程序窗体的excel导出期间格式化单元格值时遇到问题.
我有一列称为"URC代码" ,这是一个用户定义的代码,用户可以在主代码中输入 Item或Component (该代码除外)以便对其进行定义),以便根据其定义的代码来跟踪项目和组件.
该代码可以是任何东西,例如它可以是''abcd'',''xyz''之类的单词;它可以是一个数字(最多13位),例如''0331053110065'',也可以是一个十进制值,例如''13.42''.
当我将单元格NumberFormat的值保持为``0''时,它会显示''0331053110065''的正确值,但显示''13.42''的值却是错误的即,''13''(截断十进制值),当我将NumberFormat值保持为"0.00"时,它会显示''13.42''和''0331053110065''的错误值,即''3.31053E + 11''.
我的问题是,当我将项目或组件导出到excel时,应为``URC代码''列提供哪种格式,以便用户可以正确看到单元格中的数据.
I am facing a problem while formatting the cell value during excel export from a C#.Net 2.0 application form.
I have a column named as "URC Code", It''s a user defined code which the user can enter in the master for an Item or Component (other than the code with which it is defined) in order to keep a track of the items and components according to their defined code.
The code can be anything for e.g. it can be a word like ''abcd'',''xyz''; it can be a a number (upto 13 digit) like ''0331053110065'', a decimal value like ''13.42''.
When i am keeping the cell NumberFormat value to ''0'' then it shows the correct value for ''0331053110065'' but a wrong value for ''13.42'' i.e., ''13'' (truncating the decimal value) and when i am keeping the NumberFormat value to ''0.00'' then it shows the correct value for ''13.42'' and wrong value for ''0331053110065'' i.e., ''3.31053E+11''.
My problem is that when i export the items or component to excel, what formatting should i give to ''URC Code'' column so that the data in the cell is visible to user correctly.
推荐答案
这篇关于Excel导出单元格格式问题-紧急的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!