简体   繁体   English

asp.net(c#)创建Excel工作表,我是否需要在服务器上安装Excel?

[英]asp.net(c#) Create Excel Worksheet, do i need Excel installed on the server?

I have created an application that uses Microsoft.Office.Interop.Excel, in my local and testing environments everything worked fine, but the app does not work in the production environment. 我已经创建了一个使用Microsoft.Office.Interop.Excel的应用程序,在我的本地和测试环境中,一切正常,但是该应用程序在生产环境中无法正常工作。

Turns out I have Office installed locally, as does the Test server, however, the production server does not have Excel installed. 事实证明,我已经在本地安装了Office,测试服务器也安装了本地,但是生产服务器没有安装Excel。

I really can't go back and change my code, however, I would really not like to have to install Excel on the production server. 我确实无法返回并更改代码,但是,我真的不想在生产服务器上安装Excel。

Do I have any other options other than installing Office Excel on the production server to get the application working? 除了在生产服务器上安装Office Excel才能使应用程序正常工作以外,我还有其他选择吗?

Thanks, Appreciate your assistance. 谢谢,感谢您的协助。 Steven 史蒂芬

Office Interop does require that Office be installed on the server. Office Interop 确实要求在服务器上安装Office。

In the more general case, you do not need Excel to create worksheets, and you should avoid any solution that requires it for web use . 在更一般的情况下,你不需要 Excel中创建的工作表, 您应避免需要它的Web使用任何解决方案 That includes office interop: it doesn't scale in a web environment. 其中包括办公室互操作性:它无法在网络环境中扩展。

See this question for more options: 有关更多选项,请参见此问题:
Generating an Excel file in ASP.NET 在ASP.NET中生成Excel文件

Did you try to find some free cost excel components for .NET. 您是否尝试找到一些用于.NET的免费Excel组件。 For example, these two components have free version for creating excel files: 例如,这两个组件具有用于创建excel文件的免费版本:

The Excel interop libraries work by opening the Excel application in the background to process the spreadsheet. Excel互操作库通过在后台打开Excel应用程序来处理电子表格来工作。 So without updating your code, you will need to have Excel installed on the server. 因此,无需更新代码,您将需要在服务器上安装Excel。 However using interop is a very slow and error prone solution to working with Excel from ASP.NET, the link Joel gave provides several good alternatives. 但是,使用interop是从ASP.NET使用Excel的非常慢且容易出错的解决方案,Joel给出的链接提供了几种不错的选择。

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

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