使用Run an Excel Macro from SSIS
中的类似逻辑我的脚本任务逻辑在SSIS中如下,
numpy
excel(.xlsm)中可用的宏如下
import numpy as np
list1 = np.array([[390, 2645, 760, 2736], [395, 2848, 703, 2950], [399, 2747, 767, 2843], [1083, 2641, 1743, 2732], [1083, 2641, 1743, 2732], [1085, 2845, 1697, 2932], [1085, 2845, 1697, 2932], [1087, 2737, 1741, 2833], [1087, 2737, 1741, 2833], [2055, 2728, 2348, 2831], [2059, 2638, 2351, 2725], [2062, 2840, 2360, 2927], [2065, 2933, 2203, 3033]])
list2 = []
for i, ref in enumerate(list1):
close = np.abs(list1[:, 0] - ref[0]) < 200
if np.sum(close) > 0 and list1[close].tolist() not in list2:
list2.append(list1[close].tolist())
print ([len(l) for l in list2])
# [3, 6, 4]
print (list2)
# [[[390, 2645, 760, 2736], [395, 2848, 703, 2950], [399, 2747, 767, 2843]], [[1083, 2641, 1743, 2732], [1083, 2641, 1743, 2732], [1085, 2845, 1697, 2932], [1085, 2845, 1697, 2932], [1087, 2737, 1741, 2833], [1087, 2737, 1741, 2833]], [[2055, 2728, 2348, 2831], [2059, 2638, 2351, 2725], [2062, 2840, 2360, 2927], [2065, 2933, 2203, 3033]]]
以上宏被保存为Module1,当我尝试运行该程序包时,数据正在刷新,但是宏未得到执行
注意:尝试了类似文章中建议的所有解决方案
关闭仍然是错误发生的错误
重要提示:
*尝试从excel-> developer-> visual ***-> Module1->执行时执行宏,然后按预期运行。*
答案 0 :(得分:0)
ExcelObj.Run(“ Module1”,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing ,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing ,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing ,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing ,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing ,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
在这里,您只是指向"Module1"
,而不是实际的宏。 "Module1"
是"fileSave"
的保存位置。
尝试一下
更改
ExcelObj.Run("Module1",Type.Missing,.....
到
ExcelObj.Run("fileSave",Type.Missing,.....