有頗有意思的網站:https://connectionstrings.com/ace-oledb-12-0/ 很詳細得介紹了各類寫法ide
這裏主要提兩個:網站
string strCon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + excelPath + "';Extended Properties='Excel 8.0;HDR=YES;IMEX=1'"; string strCon = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + excelPath + "';Extended Properties='Excel 8.0;IMEX=1'";
這兩個適用於97-03版本的excel,後綴.xlsspa
高版本的基本用下面的這個excel
string strCon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + excelPath + "';Extended Properties='Excel 12.0;HDR=YES;IMEX=1'";