excel读取
1.读取多个excel(结构相同)中的某一列所有值。比如这列有:001,002,003......
2.把所有获取到的值拼成一句sql语句。示例:update 表名 set isFinsh=0 where aa like '%001% or aa like '%002%' or aa like '%003%'
------解决方案--------------------
select F2是读取第二列,其他类似
System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\xx.xls;Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\";");
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("select F2 from [Sheet1$]", cn);
cn.Open();
System.Data.OleDb.OleDbDataReader dr = cmd.ExecuteReader();
String strWhere="update 表名 set isFinsh=0 where ";
while(dr.Read())
{
strWhere += " aa like '%" + dr[0].ToString() + "%' or";
}
if (strWhere.EndsWith("or")) strWhere = strWhere.Substring(0, strWhere.Length - 2);
cn.Close();
strWhere之后,再继续处理
------解决方案--------------------1.用NPOI来搞
2.用string.format和SqlParameter来搞。