发布网友 发布时间:2024-10-18 22:12
共1个回答
热心网友 时间:2024-10-18 22:54
这样看看
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + dataSource + ";Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection(mystring);
DataTable dt = new DataTable();
cnnxls.Open();
dt = cnnxls.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
String sheetName = dt.Rows[0]["TABLE_NAME"].ToString();
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from ["+ sheetName +"]", cnnxls);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
热心网友 时间:2024-10-18 23:02
这样看看
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + dataSource + ";Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection(mystring);
DataTable dt = new DataTable();
cnnxls.Open();
dt = cnnxls.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
String sheetName = dt.Rows[0]["TABLE_NAME"].ToString();
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from ["+ sheetName +"]", cnnxls);
DataSet myDs = new DataSet();
myDa.Fill(myDs);