0

我在用 C# 读写 Excel 文件时有点困惑。我在我的应用程序中使用 Interop.Excel.dll。

现在这在我的本地机器上运行良好。我已经安装了 MS Excel。但是,当我在未安装 MS Excel 的服务器上运行此应用程序时,它会生成异常。

尽管我已经引用了 dll,但我是否需要安装 MS Excel。

请指导我。

这是例外。

===================START=====================
    10/27/2012 7:48:52 PM
    System.Runtime.InteropServices.COMException (0x80040154): 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)).
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
       at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at ImpExpExcelFile.Form1.generateExcel(String loginId, String fileName, DataSet newValues)
    ====================END======================

谢谢 :)

4

3 回答 3

0

我在 Expected Behavior 工作,我们有一个名为 DocRaptor 的 HTML 到 Excel 的 API,它可以将 HTML 转换为 Excel,而无需在服务器端安装 Excel。

DocRaptor 是一个 Ruby on Rails 应用程序,但您可以使用 C# 通过 HTTP POST 请求生成 Excel 文档。

这是 DocRaptor 主页的链接: DocRaptor

以及指向我们的 C# 示例代码的链接: DocRaptor C# Example

于 2012-10-29T21:53:15.283 回答
0

Ofc 你需要安装 MS Excel。Interop.Excel.dll 只是接口包装器。

于 2012-10-29T06:38:54.197 回答
0

必须安装 Excel。安装,然后重试。不使用 Excel 无法工作

于 2012-10-29T06:37:43.853 回答