An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: External table is not in the expected format.
private void button1_Click(object sender, System.EventArgs e)
{
string path = @"C:\Projects\test.xlsx";
string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
string sql = "SELECT * FROM [Sheet1$]";
using (OleDbDataAdapter adaptor = new OleDbDataAdapter(sql, connStr))
{
DataSet ds = new DataSet();
adaptor.Fill(ds);
}
}
adaptor.Fill(ds); ==> Additional information: External table is not in the expected format.