【发布时间】:2017-10-10 15:41:57
【问题描述】:
我开发了一个运行 Excel 宏的 SSIS 包(如果我没记错的话,VS2008、SQL Server 2008 和 Windows Server 2008 - 服务器已停用)。使用 SQL Server 2016 和 VS2015 将包迁移到 Azure。
我们现在是一年多来第一次运行它,但它失败了。从 SSIS 运行宏的原始代码取自这里Run an Excel Macro from SSIS。
代码:
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();
}
Public void Main 第 1 行出错:
附加信息:检索 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件的 COM 类工厂失败,原因是以下错误:80040154 未注册类(HRESULT 异常:0x80040154 (REGDB_E_CLASSNOTREG))。
虽然是手动添加了互操作参考,但因为 MS 的安装 (exe) 无法完成这项工作。也许.dll不好?请帮助并记住我是这方面的新手。
【问题讨论】:
标签: c# excel ssis sql-server-2016