gpt4 book ai didi

c# - Microsoft Office Interop Excel 不保存在 Windows Server 2008 中

转载 作者:太空宇宙 更新时间:2023-11-03 13:36:41 24 4
gpt4 key购买 nike

我正在使用 Microsoft Office Excel Interop 在 ASP.NET C# 中创建一个 excel 文件。当我在 Visual Studio 2010 中运行应用程序时,一切都成功了。我已经在我自己的 IIS 服务器上发布了我的 Web 应用程序,没问题。但是当我在 Windows Server 2008 中发布应用程序时,发现了问题。我在网上找了很多,我做了以下,但问题仍然没有解决:

  1. 我已将 Application Pool Identity 设置为 LocalSystem。在运行 -> mmc -32 -> 组件服务 -> 我的电脑 -> DCOM 配置 -> Microsoft Excel 应用程序 -> 右键单击​​ -> 属性窗口:在 Identity 选项卡中,我检查了所有 radio 此窗口中的按钮。

  2. 我已将 Application Pool Identity 设置为 NetworkService,并且我再次检查了所有之前的单选按钮。

  3. 在运行->mmc -32 -> 组件服务 -> 我的电脑 -> DCOM 配置 -> Microsoft Excel 应用程序 -> 右键单击​​ -> 属性窗口:在安全 选项卡中:我为 INTERACTIVE、NETWORK SERVICE、IIS_IUSRS 用户提供了Local LaunchLocal Activation

    这是我使用 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"));

最佳答案

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

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

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

关于c# - Microsoft Office Interop Excel 不保存在 Windows Server 2008 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18463952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com