我尝试在 c# 中阅读 .xls 苍蝇。如果第一个数据列是文本,那么它会显示DBNull.Value =true
。但是如果是数字就可以了。那么如何阅读文本呢?
这是我的代码:
OleDbCommand command = new OleDbCommand("Select [Id], [Name], [Email] from [sheet$]", connection);
OleDbDataAdapter objAdapter = new OleDbDataAdapter();
objAdapter .SelectCommand = command;
DataSet objDataset = new DataSet();
objAdapter .Fill(objDataset1);
DataView dv = objDataset .Tables[0].DefaultView;
for (int i = 0; i < dv.Count; i++)
{
if (dv[i][0] != DBNull.Value ) // problem is here.... if the first column is text then it true. I want to tead text as well.
{
}
}