I try to open the Excel file by this code.But i got an error like this

Microsoft Excel cannot access the file 'C:\XXXXExcel.xlsx'. There are several possible reasons:

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.

Plz help me..

Microsoft.Office.Interop.Excel.Workbook workBook = app.Workbooks.Open(FilePath, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
  • In what context is this code running? Within a web part, a feature, a timer job? Where is the excel file you are trying to open? Please provide more detail. – James Love Jan 4 '13 at 21:19
  • How is this related to SharePoint? – SpartanDonut Jan 4 '13 at 21:26


have a look at the OpenXML SDK. See link for examples of what you can do

Great video that explains using of Open XML sdk and also has example of using it with SharePoint

Source: Interacting with Excel spreadsheet from Sharepoint 2010

However, your answer accept rate is quite low! Please accept it if it resolves your issue!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.