在ASP.NET中dynamic生成Excel文档时出现“许可证过期”错误

任何熟悉以下错误的人? 当我运行我的web应用程序从本地机器生成一个dynamic的Excel文档时,它工作正常,但是当服务器上调用同一段代码时,我得到下面的错误。 这似乎是一个权限问题,因为它在我的机器上,但不是服务器,但我不知道从哪里开始,以查明问题。 任何指导/帮助非常感谢!

Server Error in '/' Application. -------------------------------------------------------------------------------- This command is unavailable because the license to use this application has expired. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: This command is unavailable because the license to use this application has expired. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [COMException (0x800a03ec): This command is unavailable because the license to use this application has expired.] Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template) +0 PaymentsReport.Page_Load(Object sender, EventArgs e) +70 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061 

Office / Excel安装在服务器上,我可以在服务器上打开/保存Excel文档。 难道它是服务器上的Excel版本与我的本地机器? 如果是这样,我怎么能确保我有最新的服务器?

使用Office Interop要求您正在使用的Office组件实际上安装在服务器上。

除了安装之外,还需要确保在服务器上激活应用程序:

http://support.microsoft.com/kb/294973

有关于如何做到这一点的细节。

我会带一个WAG,并说你不能在服务器上打一个旧的Office副本,让多个用户通过你的网站访问它。 您需要查看在服务器环境中使用MS Office的许可限制。

你有在服务器上的授权,激活的Excel副本? 它可能在您的本地计算机上工作,因为您在本地安装了Office / Excel。