使用OLEDB进行Excel处理 [英] Excel Processing using OLEDB

查看:92
本文介绍了使用OLEDB进行Excel处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用OLEDBConnection读取excel文件时偶尔会遇到错误。 excel文件已链接到其他数据源。

Occasionally I am getting errors, when reading excel files using OLEDBConnection. The excel file has got links to other data sources.

以下是我得到的错误

System.Runtime.InteropServices.SEHException(0x80004005):外部组件抛出异常。$
  在System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(OleDbConnectionString constr,SessionWrapper& sessionWrapper)

  在System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr,OleDbConnection连接)

   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool pool,DbConnection owningObject)

  在System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions选项,DbConnectionPoolKey poolKey,对象poolGroupProviderInfo,DbConnectionPool池,DbConnection owningConnection,DbConnectionOptions userOptions)

  在System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection,DbConnectionPoolGroup poolGroup,DbConnectionOptions userOptions)

  在System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource`1 retry,DbConnectionOptions userOptions,DbConnectionInternal& connection)

  在System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource`1 retry,DbConnectionOptions userOptions)

  在System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory)

  在System.Data.OleDb.OleDbConnection.Open()

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(OleDbConnectionString constr, SessionWrapper& sessionWrapper)
   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()



感谢是否有人可以为此提供解决方案。


Appreciate if anyone can provide solution into this.

推荐答案

这个错误太通用了我害怕。您在打开外部文档时遇到问题。它可能是任何原因,从网络错误到已经在只读模式下打开它的人。也可能与泄漏资源有关,取决于你的应用运行多长时间
This error is too generic I'm afraid. You're having issues opening an external document. It could be any # of reasons ranging from a network error to someone already having it open in read only mode. Could also be related to leaking resources, depending upon how long your app has been running.


这篇关于使用OLEDB进行Excel处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆