c# OLEDB 读取excel

string connStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source ='" + Server.MapPath(filename) + "';Extended Properties='Excel 8.0;HDR=No;IMEX=1'";
OleDbConnection conn = new OleDbConnection(connStr);
conn.Open();
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", conn);
DataSet ds = new DataSet();
myDa.Fill(ds, "xls");
conn.Close();

你可能感兴趣的:(Excel)