2

I am using Microsoft Office Excel Interop to create an excel file in ASP.NET C#. Everything is successful when I am running application in Visual Studio 2010. I have published my web application in my own IIS server, it is ok. But when I publish application in Windows Server 2008, the problem was detected. I looked for much in internet and i have done following, but the problem still was not solved:

  1. I have set Application Pool Identity to LocalSystem. In Run -> mmc -32 -> Component Services -> My Computer -> DCOM Config -> Microsoft Excel Application -> right-click -> Properties window: in Identity tab, I have checked all radio buttons in this window.

  2. I have set Application Pool Identity to NetworkService, and I have checked all previous radio buttons again.

  3. In Run->mmc -32 -> Component Services -> My Computer -> DCOM Config -> Microsoft Excel Application -> right-click -> Properties window: in Security tab: I gave Local Launch and Local Activation for INTERACTIVE, NETWORK SERVICE, IIS_IUSRS users.

    Here is my code which I used Interop Excel:

Excel.Application xlApp = new Excel.Application();
object misValue = System.Reflection.Missing.Value;

Excel.Workbook xlWorkBook = xlApp.Workbooks.Add(misValue);
Excel.Worksheet xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
  
Workbook.SaveAs(Server.MapPath("DownloadFolder\\" + fileName + "_siyahi.xls"));
4

1 回答 1

1

我发现了我的问题。在我的 Windows Server 系统中,区域设置不是美国,我在代码中设置了worksheet.cells.NumberForm="0.00"

xlWorkSheet.Cells[rowNumber, 4].NumberFormat = "0.00";

服务器不知道这种数字格式。我已将格式更改为英语(美国)并将当前位置更改为美国,我的问题已解决。

于 2013-08-28T06:33:37.193 回答