2017-10-10 189 views
0

我开发了一个运行Excel宏的SSIS包(如果我没有记错的话 - VS2008,SQL Server 2008和Windows Server 2008 - 服务器退役了)。该软件包使用SQL Server 2016和VS2015迁移到Azure。从ssis运行宏

我们现在第一次运行它一年多了,并且失败了。用于从SSIS运行宏的原始代码取自Run an Excel Macro from SSIS

代码:公共无效的主要的1号线

using System; 
using System.Data; 
using System.Diagnostics; 
using System.IO; 
using System.IO.Compression; 
using System.Windows.Forms; 
using System.Runtime.InteropServices; 
using Microsoft.Office.Interop; 
using Excel = Microsoft.Office.Interop.Excel; 

public void Main() 
{ 
    Excel.Application xlApp = new Excel.Application(); 
    Excel.Workbook xlWorkBook = xlApp.Workbooks.Open("C:\\ExcelDirectory\\DATA.xlsm"); // absolute path needed 
    xlApp.Run("Formatting"); // method overloads allow you to send it parameters, etc. 
    xlWorkBook.Close(true); // first parameter is SaveChanges 
    xlApp.Quit(); 
} 

错误:

Additional information: 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)).

的Interop提及,虽然由于手动安装从MS(EXE)不会做的工作增加。也许.dll的不好?请帮助并记住我是这方面的新手。

回答

0

问题解决!!正如其他人在其他帖子中指出的那样,我需要安装Office。互操作本身不会运行宏或与Office产品交互。