How to handle exception in "C#" for the errors like->
Code:
Workbooks.Open(folderPath,filename,Excel.XlPlatform.xlWindows,"",""....)
"System.Runtime.InteropServices.COMException (0x80070BBC): Office has detected a problem with this file. To help protect your computer this file cannot be opened.
at Excel.Workbooks.Open"
Few excels work without error,but few throw above error. Please suggest some answers. Thanks.
Try following code to open Excel file:
String connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFilePath + ";Extended Properties=Excel 12.0;";
// Create connection object by using the preceding connection string.
OleDbConnection objConn = new OleDbConnection(connString);
// Open connection with the database.
objConn.Open();
User contributions licensed under CC BY-SA 3.0