62,046
社区成员
发帖
与我相关
我的任务
分享
if (type == ".xls")
{
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sourceTableName + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
}
else if (type == ".xlsx")
{
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sourceTableName + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
}
query = "SELECT * FROM [Sheet1$]";
//Create the connection object
conn = new OleDbConnection(strConn);
//Open connection
if (conn.State == ConnectionState.Closed)
conn.Open();