C# - 读取 .xlsx 文件失败返回 ISAM 错误消息
C# - Reading .xlsx file failed returning ISAM error message
我正在尝试访问一个我想阅读的 .xlsx 文件,我是这样做的:
protected void btnImportList_Click(object sender, EventArgs e) {
string connnection = @"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\Users\Karl\Desktop\NESR data\Autoload Sample - Goals.xlsx;Extended Properties=\Excel 12.0 xml;HDR=YES;IMEX=1\;";
OleDbConnection con = new OleDbConnection(connnection);
OleDbCommand command = new OleDbCommand();
DataTable dt = new DataTable();
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [DL JV + VS Final$]", con);
myCommand.Fill(dt);
Console.Write(dt.Rows.Count);
}
但是,我收到以下错误消息:
Could not find installable ISAM
我安装了 Microsoft AccessDatabase Manager,就像网上说的那样,但我仍在努力弄清楚我还能做些什么来解决这个问题。有什么想法吗?
使用下面的连接字符串,
string connnection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Karl\Desktop\NESR data\Autoload Sample - Goals.xlsx; Extended Properties=Excel 12.0;"
'Data' 和 'Source' 之间应该有一个 space 并删除了 HDR=YES,IMEX=1。
我正在尝试访问一个我想阅读的 .xlsx 文件,我是这样做的:
protected void btnImportList_Click(object sender, EventArgs e) {
string connnection = @"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\Users\Karl\Desktop\NESR data\Autoload Sample - Goals.xlsx;Extended Properties=\Excel 12.0 xml;HDR=YES;IMEX=1\;";
OleDbConnection con = new OleDbConnection(connnection);
OleDbCommand command = new OleDbCommand();
DataTable dt = new DataTable();
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [DL JV + VS Final$]", con);
myCommand.Fill(dt);
Console.Write(dt.Rows.Count);
}
但是,我收到以下错误消息:
Could not find installable ISAM
我安装了 Microsoft AccessDatabase Manager,就像网上说的那样,但我仍在努力弄清楚我还能做些什么来解决这个问题。有什么想法吗?
使用下面的连接字符串,
string connnection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Karl\Desktop\NESR data\Autoload Sample - Goals.xlsx; Extended Properties=Excel 12.0;"
'Data' 和 'Source' 之间应该有一个 space 并删除了 HDR=YES,IMEX=1。