string path = "C:\\Users\\aaa\\Desktop\\aa.xls";
string conn = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source =" + path + ";Extended Properties='Excel 8.0;HDR=False;IMEX=1'"; OleDbConnection oleCon = new OleDbConnection(conn); oleCon.Open(); string Sql = "select * from [Sheet1$]"; OleDbDataAdapter mycommand = new OleDbDataAdapter(Sql, oleCon); DataSet ds = new DataSet(); mycommand.Fill(ds, "[Sheet1$]"); oleCon.Close(); int count = ds.Tables["[Sheet1$]"].Rows.Count; MessageBox.Show(count+""); for (int i = ; i < count; i++)
{ string tUserID, tUserName, tDept, tEmail, tLeader, tAngent; tUserID = ds.Tables["[Sheet1$]"].Rows[i][].ToString().Trim(); tUserName = ds.Tables["[Sheet1$]"].Rows[i][].ToString().Trim();
tDept = ds.Tables["[Sheet1$]"].Rows[i][].ToString().Trim(); MessageBox.Show(tUserID + "," + tUserName + "," + tDept); }
05-26 22:47