62,025
社区成员
发帖
与我相关
我的任务
分享
OleDbConnection cnnxls = null;
//try
//{
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + filename + "'" + ";Extended Properties=Excel 8.0";
cnnxls = new OleDbConnection(mystring);
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
if (myDs.Tables[0].Rows.Count > 0)
{
return myDs.Tables[0];
}
else
{
return null;
}
cnnxls.Close();
//}
//catch (Exception ee)
//{
// WebCommon.WebMsgBox(this, ee.Message);
// cnnxls.Close();
// return null;
//}
//finally
//{
// if (cnnxls != null)
// {
// cnnxls.Close();
// }
//}