簡體   English   中英

Microsoft.Office.Interop.Excel._Workbook.SaveAs() 異常:0x800A03EC

[英]Microsoft.Office.Interop.Excel._Workbook.SaveAs() Exception: 0x800A03EC

在服務器上運行時,我在保存 excel 電子表格時遇到問題,在本地運行時,它工作得很好!

有沒有人以前遇到過這個或者可以指出我正確的方向?

應用程序池在“LocalSystem”身份下運行。

謝謝!

我不斷收到以下錯誤/堆棧跟蹤:

Error saving the excel sheet: 
Exception from HRESULT: 0x800A03EC   at     Microsoft.Office.Interop.Excel._Workbook.SaveAs(Object Filename, Object FileFormat, 
Object     Password, Object WriteResPassword, Object ReadOnlyRecommended, Object 
CreateBackup,     XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object 
AddToMru, Object     TextCodepage, Object TextVisualLayout, Object Local)
   at MiFiveDayReport.ExportToExcel.SaveAs(String filepath, XlFileFormat type) in
G:\Development\MI Development\Technical     Development\MIPortal\MIPortal\Old_App_Code\ExportToExcel.cs:line 411

這是我用來嘗試保存 excel 文檔的代碼:

try
        {
            if (log.IsInfoEnabled) log.Info("Saving...");
            if (string.IsNullOrEmpty(filepath))
                //Sets the filepath as the default
                excelBook.SaveAs(this.filepath, type);
            else
                excelBook.SaveAs(filepath, type);
            if (log.IsInfoEnabled) log.Info("Saved!");
            success = true;
        }
        catch (Exception ex)
        {
            //SendEmail e = new SendEmail("Error saving excel sheet: " + ex.Message);
            //SendEmail e1 = new SendEmail("Error saving excel sheet: " + ex.StackTrace);
            if (log.IsErrorEnabled) log.Error("Error saving the excel sheet: "
                                     + ex.Message
                                     + ex.StackTrace);
            throw;
        }

更新了新錯誤:

Error creating excel application: Retrieving the COM class factory for component with
CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 
80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).   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 MiFiveDayReport.ExportToExcel..ctor(String filepath) in G:\Development\MI Development\Technical Development\MIPortal\MIPortal\Old_App_Code\ExportToExcel.cs:line 94

在以下行中:

try
        {
            if (log.IsInfoEnabled) log.Info("Creating an excel application...");
            excelApp = new Application();
            if (log.IsInfoEnabled) log.Info("Excel application created");
        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled) log.Error("Error creating excel application: " + ex.Message + ex.StackTrace);
            throw;
        }

1)開始->運行-> mmc -32->按Enter將打開新窗口2)文件->添加刪除管理單元->從可用管理單元中選擇組件服務->按添加>按鈕3)展開組件服務->展開計算機->展開mycomputer->展開DCOM配置->右鍵單擊Microsoft Excel應用程序->屬性->安全選項卡4)在啟動和激活權限部分中->單擊自定義單選按鈕,然后單擊編輯按鈕5)單擊添加按鈕->添加您的用戶並提供對該用戶的所有訪問權限,然后按確定按鈕(您正在使用的服務帳戶正在執行您的應用)

在此之后,請創建以下提到的文件夾

如果我們在64位/ R2的Windows Server 2008中運行,·導航到C:\\ Windows \\ SysWOW64 \\ config \\ systemprofile文件夾並創建以下目錄“ Desktop”如果我們在32位的Windows Server中運行·導航至C :\\ Windows \\ System32 \\ config \\ systemprofile \\ Desktop文件夾並創建以下目錄“ Desktop”

這樣可以解決這個問題。

我已經死了又回來了 Microsoft.Office.Interop.Excel.Workbook,我發現修復不使用 C:\ 驅動器在我的 AWS windows 系統上,而是 D:\ 驅動器。 關於 C: 驅動器的安裝方式的一些事情打破了 Microsoft.Office.Interop.Excel.Workbook SaveAs2 function 調用。 我嘗試了很多在網上找到的其他常見修復方法,但這是唯一對我有用的方法。

暫無
暫無

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

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