簡體   English   中英

用C#讀寫Excel文件

[英]Read Write Excel File in c#

用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======================

謝謝 :)

必須安裝Excel。 安裝,然后重試。 無法使用Excel工作

您需要安裝MS Excel。 Interop.Excel.dll僅是接口包裝器。

我在Expected Behavior上工作,我們有一個名為DocRaptor的HTML to Excel API,可以將HTML轉換為Excel,而無需在服務器端安裝Excel。

DocRaptor是Ruby on Rails應用程序,但是您可以使用C#通過HTTP POST請求生成Excel文檔。

這是DocRaptor主頁的鏈接: DocRaptor

以及指向我們的C#示例代碼的鏈接: DocRaptor C#示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM