如何在 VSTS 中构建包含 Excel 创建的项目?

How can I build a project containing Excel creation in VSTS?

我有一个使用 Interop Excel 构建报告的项目。这 运行 没问题,每次都会创建报告。

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

var excelApp = new Excel.Application();

下面是个例外,我已经添加了对程序集的多个引用,但我不确定我是否可能遗漏了一些对 运行 的 COM 引用。

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。

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.