I would like to count the number of empty cell in Excel sheet.
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.
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
the result of the expression is always 'false' since a value of type 'double' is never equal to 'null' of the type 'double?'
What should I do?