我有一个功能:

   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
     }

我正在使用Microsoft.interop库从Excel表读取并将其保存到数据库中。这里的问题是,当代码尝试在IIS 8上打开工作簿时,我会得到“对象参考未设置为对象的实例”。它在Visual Studio 2010上运行良好。问题可能是问题所在。

有帮助吗?

解决方案

我必须允许IIS用户使用该应用程序。创建一个文件夹C: Windows Syswow64 config SystemProfile SystemProfile Desktop,用于64位系统,并设置权限设置以允许IIS用户。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top