开发者

how to read an excel file that is readonly from c#?

开发者 https://www.devze.com 2023-01-07 17:46 出处:网络
I am trying to do that by using OleDb but the file is protected by a password which i dont have. So it gives the followi开发者_StackOverflow社区ng error when i open the connection:

I am trying to do that by using OleDb but the file is protected by a password which i dont have. So it gives the followi开发者_StackOverflow社区ng error when i open the connection: Cannot update. Database or object is read-only. How can i solve this? thanks


Read password protected excel file using OLEDB in C#


You need to specify your UserId and Password in your Connection String same as with a SQL connection. Unfortunately, this means that you'll have to get the password.

If you can't get the password, you might be able to open the spreadsheet in Read-Only mode and copy the data from it into a new spreadsheet and read that one...


Assuming you're talking about an Excel file that you're allowed to view but that's locked for editing with a password. I'm fairly certain that OleDB won't support that.

You could probably open the file using Excel Automation and copy the data into your app from there however.

0

精彩评论

暂无评论...
验证码 换一张
取 消