读取Excel文件转成DataTable

DataSet ds=new DataSet();
    string connStr="provider=MicroSoft.Jet.OLEDB.4.0;Data Source="+strFileName+";Extended Properties=Excel 8.0";
    
    string commStr="select * from ["+GetResellerType(ResellerType)[1].ToString()+string.Format("$] where 渠道编号<>'' ",ResellerType);       
    
    OleDbConnection myConn=new OleDbConnection(connStr);
    OleDbCommand myComm=new OleDbCommand(commStr);
    OleDbDataAdapter myAd=new OleDbDataAdapter(commStr,connStr);
    myAd.Fill(ds);
    myConn.Close();
    return ds.Tables[0];

你可能感兴趣的:(Datatable)