簡體   English   中英

Excel:處理workbook.open的異常

[英]Excel:Handle exception for workbook.open

如何處理在“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"

擅長工作的幾乎沒有錯誤,但很少有人會出錯。 請提出一些答案。 謝謝。

嘗試使用以下代碼打開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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM