消息说
Microsoft Access 数据库引擎找不到对象“Sheet1$”。确保对象存在并且正确拼写其名称和路径名。如果“Sheet1$”不是本地对象,请检查您的网络连接或联系服务器管理员。
工作表中工作表的名称是“Sheet1”
string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES"";", fileName);
string query = String.Format("SELECT [columnName1],[columnName2],[columnName3] from [{0}]", "Sheet1$");
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
DataTable YourTable = dataSet.Tables[0];
listBox1.DataSource = YourTable.Columns["ColumnName1"];