从.net调用excel UDF? [英] Calling excel UDF from .net?
问题描述
我试图从C#调用excel中的UDF吗?当我从头开始打开excel时-> pro UDF函数起作用,但是当我尝试应用公式时从C#自动化中我得到Name?#下面的任何帮助都是代码迭代
I am trying to call UDF in excel from C#?When I open the excel from start-->pro the UDF function works.but when I try to apply the formula from C# automation I am getting Name?# any help below is the code itried
Microsoft.Office.Interop.Excel.Application oXL =新的Microsoft.Office.Interop.Excel.Application();oXL.Visible = true;Microsoft.Office.Interop.Excel._Workbook oWB;Microsoft.Office.Interop.Excel._Worksheet oSheet;
Microsoft.Office.Interop.Excel.Application oXL = new Microsoft.Office.Interop.Excel.Application(); oXL.Visible = true; Microsoft.Office.Interop.Excel._Workbook oWB; Microsoft.Office.Interop.Excel._Worksheet oSheet;
oWB = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(System.Reflection.Missing.Value));
oXL.AddIns.Add("ciqfunctions.udf", false)
Microsoft.Office.Interop.Excel.AddIn adc = oXL.AddIns.Item["Capital IQ Worksheet Functions"];
adc.Installed = true;
oXL.AddIns.Add("ciqfunctions.udf", false).Installed = true;
all below register xlls returns false.any idea
bool clloaded = oXL.RegisterXLL(@"C:\Program Files\Capital IQ\Office Plug-in\ciqfunctions.xll");
bool clloaded1 = oXL.RegisterXLL("ciqfunctions.xll");
bool clloaded2 = oXL.RegisterXLL("ciqfunctions.udf");
bool clloaded3 = oXL.RegisterXLL(oXL.DefaultFilePath + "\\CIQAddinLib.dll");
I am applying formula by creating range
and range.formula ="=一些udf公式",但是它放了Name#?任何想法
and range.formula="=some udf formula" but it puts Name#? any idea
推荐答案
我认为这行没问题,应该可以正常工作,
I think this line is ok and should work, almost:
oXL.AddIns.Add("ciqfunctions.udf", false).Installed = true;
至少根据我的阅读.尝试使用文件的完整路径(您的情况就是这样):
at least according to my readings. Try it with the full path of the file which in your case is this one:
@"C:\Program Files\Capital IQ\Office Plug-in\ciqfunctions.xll"
其他一切似乎都没问题,步骤也显示在这里:
everything else seems to be ok, steps are also shown here:
这篇关于从.net调用excel UDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!