简体   繁体   English

Microsoft Interop库:无法在IIS8中打开Excel工作簿

[英]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. 我正在使用Microsoft.Interop库从Excel工作表读取并将其保存到数据库。 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. 这里的问题是,当代码尝试在IIS 8上打开工作簿时,出现“对象引用未设置为对象实例”的异常。它在Visual Studio 2010上运行良好。这可能是问题所在。

I had to give IIS User permission to use the Application. 我必须授予IIS用户使用该应用程序的权限。 Create a folder C:\\Windows\\SysWOW64\\config\\systemprofile\\Desktop for 64-bits Systems and set the permission settings to allow for IIS user. 为64位系统创建一个文件夹C:\\ Windows \\ SysWOW64 \\ config \\ systemprofile \\ Desktop,并将权限设置设置为允许IIS用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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