【发布时间】:2011-10-09 14:03:37
【问题描述】:
我试图用 C# 代码读取 HTML 类型的 Excel 文件。 我收到“未指定的错误”。
这是我的连接字符串:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='HTML Import; // c:\1.xls
这是我的代码:
private string GetTableName(OleDbConnection conn)
{
string tableName = null;
try
{
conn.Open();
var dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (dt == null)
{
log.Error("Table schema is not available.");
return tableName;
}
tableName = dt.Rows[0]["TABLE_NAME"].ToString();
}
catch (Exception e)
{
log.Warn(e);
return null;
}
finally
{
conn.Close();
}
return tableName;
}
我查遍了互联网和谷歌,没有人遇到完全相同的问题。
我想了解我的代码有什么问题或“未指定错误”是什么意思?!
谢谢!!!
【问题讨论】:
-
如果我没记错的话,其中一个 windows xp 服务包更改了 jet 驱动程序周围的安全设置并读取 html 表格,但我在我正在考虑的 msdn 上找不到该文档。它基本上限制了读取 html 表格的能力。如果我找到它,我会回来并发布链接。祝你好运
-
查看support.microsoft.com/kb/240770 有一个部分讨论“DisabledExtensions”
标签: c# excel connection-string