如何在VSTS中构建包含Excel创建的项目? [英] How can I build a project containing Excel creation in VSTS?

查看:96
本文介绍了如何在VSTS中构建包含Excel创建的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Interop Excel生成报告的项目.这样就可以正常运行,并且每次都会创建报告.

I have a project that uses Interop Excel to build up a report. This runs just fine and the report is created every time.

我现在面临的问题是发布时,我无法运行它,它已构建并发布,但是当我尝试使用此行创建Excel文件时出现异常:

The problem that I'm facing now is when published, I'm not able to run it, it is built and published but I get an exception when I try to create the Excel file with this line:

var excelApp = new Excel.Application();

下面是一个例外,我为程序集添加了多个引用,但是我不确定是否缺少一些COM引用来运行该程序.

The exception is the one below, I've added multiple references to assemblies but I'm not sure if maybe I'm missing some COM reference for this to run.

未处理的异常:System.Runtime.InteropServices.COMException:由于以下错误,检索具有CLSID {00024500-0000-0000-C000-000000000046}的组件的COM类工厂失败:80040154未注册类(HRESULT的异常: 0x80040154(REGDB_E_CLASSNOTREG).

Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

推荐答案

毕竟,Azure应用程序服务不允许Office.我采用的方式是OpenXML.

After all, Azure app service does not allow Office. The way I took was OpenXML.

简而言之,我们不能在Azure WebApp服务上使用它. Azure WebApp服务上不存在MS Office互操作,并且Azure WebApp是沙箱.如果要在Azure WebApp上读写Excel文件,可以使用DocumentFormat.OpenXml作为解决方法.

In short, we can't use it on the Azure WebApp service. There is no MS Office inter-op present on Azure WebApp service and Azure WebApp is sandbox. If we want to write and read excel file on the Azure WebApp, we could use the DocumentFormat.OpenXml as workaround.

这篇关于如何在VSTS中构建包含Excel创建的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆