medusa
medusa

Reputation: 541

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

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 following error when i open the connection: Cannot update. Database or object is read-only. How can i solve this? thanks

Upvotes: 1

Views: 1258

Answers (3)

Hans Olsson
Hans Olsson

Reputation: 55009

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.

Upvotes: 0

Logan Young
Logan Young

Reputation: 431

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...

Upvotes: 0

Related Questions