使用OleDB从受密码保护的Excel文件中获取数据 [英] Get data from password protected Excel file using OleDB

查看:132
本文介绍了使用OleDB从受密码保护的Excel文件中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此连接字符串访问excel(2007,2010)文件

I'm using this connection string to access excel(2007,2010) files

oleConnection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath + ";Extended Properties='Excel 12.0;HDR = NO;IMEX = 1;'";

这项工作正常,直到我尝试从受保护列表中获取数据. 我知道保护密码. 那么我该如何访问受保护列表?

this work fine until i try to get data from protected List. I know the protection password. So how could i access protected list?

推荐答案

按照 MSDN ,您可以为凭据提供连接字符串User ID=UserX;Password=UserXPassword,但这可用于访问

As per MSDN you can provide the credentials with the connection string User ID=UserX;Password=UserXPassword but this works for access

但是

恐怕.您无法打开与受密码保护的连接 电子表格,除非您已经在中手动打开了电子表格 Excel.所描述的错误与 Excel ODBC提供程序,但在Jet 4.0 OLE中的行为是相同的 数据库提供者.您的另一个选择是从 电子表格,并依靠其他一些安全机制(例如 限制文件所在文件夹的权限) 控制访问权限.

I'm afraid. You cannot open a connection to a password-protected spreadsheet unless you have already manually opened the spreadsheet in Excel . The described error is with the Excel ODBC provider, but the behavior is identical in the Jet 4.0 OLE DB provider. Your other option is to remove the password from the spreadsheet, and rely on some other security mechanism (like restricting permissions on the folder where the file resides) to control access.

这篇关于使用OleDB从受密码保护的Excel文件中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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