简体   繁体   中英

Microsoft Office Interop Excel doesn't save in Windows server 2008

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"));

I found my problem. In my Windows Server system regional settings haven't been United States and I have set worksheet.cells.NumberForm="0.00" in my code.

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

Server doesn't knows this number format . I have changed Format to English (United States) and Current location to United States and my problem solved.

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