【问题标题】:what is this value means 1.845E-07 in excel?这个值是什么意思 1.845E-07 在 excel 中?
【发布时间】:2023-10-25 02:22:01
【问题描述】:

我正在使用互操作服务从 C# 读取 excel 表。我的工作表有一个单元格值为 0.00。但是当我在 C# 代码中检查该单元格的值时,运行时我得到“1.845E-07”这个值。当我签入 Excel 表时,在该单元格上右键单击,说格式单元格,我在示例部分得到“1.845E-07”值。如何获得准确的价值? 请帮我。代码很大,所以我不能在这里提供。 那行是:

if (Convert.ToString(((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2) != string.Empty)
{
    drRow[dtSourceEXLData.Columns[constants.Floor]] = ((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2.ToString();
}

日期单元格“39448”也有同样的问题。这是什么意思??请帮忙....

【问题讨论】:

    标签: excel scientific-notation


    【解决方案1】:

    1.84E-07 是精确值,使用scientific notation 表示,也称为指数表示法。

    1.845E-07 与 0.0000001845 相同。 Excel 会将非常接近 0 的数字显示为 0,除非您修改单元格的格式以显示更多小数。

    但是,C# 将从单元格中获取实际值。 ToString 方法在将小数字转换为字符串时使用电子表示法。

    如果不想使用电子符号,可以指定格式字符串。

    【讨论】:

    • 但是如何指定它的字符串??请步骤。
    • 干得好...现在对象 testval = ((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2;双 dbl1 = Convert.ToDouble(testval); //if (Convert.ToString(((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2) != string.Empty) if (testval != null && testval != string.Empty) { drRow[dtSourceEXLData .Columns[constants.Floor]] = dbl1.ToString("F");//((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2.ToString(); }
    【解决方案2】:

    突出显示单元格,格式化单元格,选择自定义,然后选择零。

    【讨论】: