[英]Checking for null value (Empty Cell) in Excel file
I would like to count the number of empty cell in Excel sheet. 我想计算Excel工作表中空白单元格的数量。
I read the double values for all Excel sheet but I can't count the null values since the code below does not work probably. 我读取了所有Excel工作表的双精度值,但由于下面的代码可能无法工作,因此我无法计算空值。
string path_connection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + testbox_bath.Text + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";
OleDbConnection connection = new OleDbConnection(path_connection);
OleDbDataAdapter adapter_STDsamverkan = new OleDbDataAdapter("Select [Kvalitetsklass (null)],[Std samverkan (null)]" + "from [Sheet1$]", connection);
DataTable dt_STDsamverkan = new DataTable();
adapter_STDsamverkan.Fill(dt_STDsamverkan);
for (int i = 0; i < dt_STDsamverkan.Rows.Count; i++)
{
if (dt_STDsamverkan.Rows[i].Field<double>(1) == null)
{
STDsamverkan_count2++;
}
}
The hint on the IF statement is IF语句上的提示是
the result of the expression is always 'false' since a value of type 'double' is never equal to 'null' of the type 'double?'
表达式的结果始终为“ false”,因为类型为“ double”的值从不等于类型为“ double”的“ null”?
What should I do? 我该怎么办?
I use Double in reading Datatable. 我在读取数据表时使用Double。 The double is nullable.
双精度为空。
The answer for this question under the link below: 在下面的链接下该问题的答案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.