我在用 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======================
谢谢 :)