ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + fileName + "'; Extended Properties=Excel 5.0"
Dim ExcelConnection As System.Data.OleDb.OleDbConnection
ExcelConnection = New System.Data.OleDb.OleDbConnection(ConnectionString)
ExcelQuery = "Select * from [Sheet2$]"
Dim ExcelCommand As New System.Data.OleDb.OleDbCommand(ExcelQuery, ExcelConnection)
ExcelConnection.Open()
Dim ExcelReader As System.Data.OleDb.OleDbDataReader
ExcelReader = ExcelCommand.ExecuteReader()
While (ExcelReader.Read)
End While
ExcelConnection.Close()
ExcelReader.Close()
行上发生错误
ExcelConnection.Open()
External table is not in the expected format.
请帮忙 谢谢
答案 0 :(得分:2)
使用
public static string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=Excel 12.0;";
作为您的连接字符串。在此处查找更多信息:Excel "External table is not in the expected format."。