Search code examples
c#exceloledb

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


Solution

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