我想打开一个xlsx文件,我尝试了下面的代码,但它既不能打开也没有抛出任何错误。
有人能帮忙解决一下吗?
string path = "C:\\examples\\file1.xlsx";
string connString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";");
OleDbConnection cn = new OleDbConnection(connString);
cn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", cn);
DataTable dt = new DataTable();
adapter.Fill(dt);