简体   繁体   中英

Microsoft Interop Library: Cannot open excel workbook in IIS8

I have a function thus:

   public static void ProcessWorkSheet(string fileName, string month, string year,
     string thread)
    {
        //version number location
        int version_row = 10;
        int version_column = 2;

        SeedsDBEntities db = new SeedsDBEntities();

        try
        {
            //Instance of Excel
            ExcelApp = new Microsoft.Office.Interop.Excel.Application();

            ExcelApp.Visible = true;

            ExcelApp.DisplayAlerts = false;

            WorkBook = ExcelApp.Workbooks.Open(@fileName, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
            (Microsoft.Office.Interop.Excel.Worksheet)WorkBook.Worksheets.get_Item(month);
                    .
                    .

            //the rest of the code
     }

I am using Microsoft.Interop library to read from an excel sheet and save it to a database. the issue here is that i get an "Object reference not set to an instance of an object" exception when the code tries opening the workbook on IIS 8. It works well on visual studio 2010. What could be the problem.

I had to give IIS User permission to use the Application. Create a folder C:\\Windows\\SysWOW64\\config\\systemprofile\\Desktop for 64-bits Systems and set the permission settings to allow for IIS user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM