打开Excel文件时出现异常

shr*_*yak 5 c# office-interop excel-interop

我有一个Excel文件,在手动打开时会出错:

excel found unreadable content in *****.xlsx. Do you want to recover the content of this workbook? If you trust this workbook click yes.

如果我单击是,我可以通常的方式打开它,但如果我使用:

Excel.Application oExcelApp;
Excel.Workbook excelWorkbook = oExcelApp.Workbooks.Open(workbookPath, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
Run Code Online (Sandbox Code Playgroud)

我收到一个COMException:

Exception from HRESULT: 0x800A03EC

如何处理此异常.如何将其打开或显示每次手动打开时显示的错误.

我正在使用MS Office 2010.

tob*_*ter 1

尝试将第四个参数类型更改为 XlFileFormat (枚举)并选择合适的值(枚举描述)。也许 5 (枚举中的xlWK1值)是错误的......

例如

Excel.Application oExcelApp;
Excel.Workbook excelWorkbook = oExcelApp.Workbooks.Open(workbookPath, 0, false, Excel.XlFileFormat.xlWorkbookDefault, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
Run Code Online (Sandbox Code Playgroud)