My connection string is:
String excelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("abc.xls") + ";Extended Properties='Excel 8.0; HDR=YES;IMEX=1'";
OleDbConnection conn = new OleDbConnection(excelConn);
Conn.Open();
It gives an error, like “Could not decrypt file.” If my Excel file (abc.xls) is close in my client PC. But it is ok when my excel file is open.
you cannot connect to a password protected excel file with OleDbConnection, it won’t work by design.
Check here: Open a password-protected Excel workbook