.net 如何在 Excel 中表达 NaN 值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15704538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I express NaN values in Excel?
提问by WhiskerBiscuit
I'm writing a .NET program which generates an XML document that is opened in Excel. The cell's typically look like:
我正在编写一个 .NET 程序,它生成一个在 Excel 中打开的 XML 文档。单元格通常看起来像:
<ss:Cell>
<ss:Data ss:Type="Number">123</ss:Data>
</ss:Cell>
But occasionly the value I'm writing has either NaN, DIV/0, or INF. In these cases 123 would be replaced by that text value and Excel won't open the file because of the text.
但有时我写的值有 NaN、DIV/0 或 INF。在这些情况下,123 将被该文本值替换,并且 Excel 不会因为该文本而打开该文件。
I don't think Excel has constants, so I'm unsure of how to handle this siutation, other than put a "-1" value in instead. Any suggestions?
我不认为 Excel 有常量,所以我不确定如何处理这种情况,除了输入“-1”值。有什么建议?
回答by Reinier Torenbeek
Here are the different error-codes that Excel knows about, stored in XML format:
以下是 Excel 知道的不同错误代码,以 XML 格式存储:
<Cell><Data ss:Type="Error">#DIV/0!</Data></Cell>
<Cell><Data ss:Type="Error">#NUM!</Data></Cell>
<Cell><Data ss:Type="Error">#VALUE!</Data></Cell>
<Cell><Data ss:Type="Error">#N/A</Data></Cell>
<Cell><Data ss:Type="Error">#NAME?</Data></Cell>
<Cell><Data ss:Type="Error">#REF!</Data></Cell>
<Cell><Data ss:Type="Error">#NULL!</Data></Cell>
Only the first two are relevant for your question, but I added the others for the sake of completeness.
只有前两个与您的问题相关,但为了完整起见,我添加了其他的。
But occasionly the value I'm writing has either NaN, DIV/0, or INF
但有时我写的值有 NaN、DIV/0 或 INF
DIV/0maps to #DIV/0!. I do not think there is a distinction between NaNor INFin Excel, they both seem to be expressed as #NUM!. For example, both of the following formulas resulted in #NUM!, even though the first one is an invalid number whereas the second one is just very large.
DIV/0映射到#DIV/0!. 我不觉得有什么区别NaN或INFExcel中,他们似乎都可以表示为#NUM!。例如,以下两个公式的结果都是#NUM!,即使第一个是无效数字而第二个非常大。
=ASIN(2)
=EXP(EXP(10))
Interesting, tough hardly useful: Excel allows you to enter these literal error values (including all punctuation) into cells on your worksheet without a problem. In a sense, these arebuilt-in constants.
有趣但几乎没有用处:Excel 允许您将这些文字错误值(包括所有标点符号)输入到工作表上的单元格中而不会出现问题。从某种意义上说,这些是内置常量。

