0

如何在“C#”中为错误处理异常,例如->

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"

很少有优秀的作品没有错误,但很少有人能超越错误。请提出一些答案。谢谢。

4

1 回答 1

0

尝试以下代码打开 Excel 文件:

    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();
于 2012-10-31T12:57:00.923 回答