本文介绍了从C#调用XLL文件中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有功能的xll文件,我想从C#调用该功能.这个xll文件用在excel中.任何人都知道怎么做吗?.我试着刷新xll文件,但我没有得到值.如果我像开始->程序-> excel这样打开excel,在excel中,如果我直接给出该函数,我将获得正确的值.如果我在c#中自动执行excel,并从Microsoft.Office.Interop.Excel中打开excel,并应用了该函数,则会出错

I have a xll file which have a function and I want to call that function from C#.This xll file is used in excel.any body have idea how to do that?.I tried refrencing the xll file but I am not getting the value.If I open excel like start-->programms-->excel and in excel if i directly give the function I am getting right value.Same thing If i automate excel in c# and opened excel from Microsoft.Office.Interop.Excel and applied the function I am getting error

推荐答案

您可以使用一些工具:

XLL Plus
XLL主机

在MSDN 使用C#中的XLL ,这是答案:

The question has also been asked on MSDN Use XLL from C#, this is the answer:

如果需要从dll创建.NET程序集,则可以尝试使用类型库导入工具围绕dll创建包装器:

If you need to create a .NET assembly from the dll, you can try to use Type Library Import tool to create a wrapper around the dll:

tlbimp.exe xll.dll /out:xllnet.dll


我给出了所有3条建议,但没有任何运气.鉴于XLL工具的作者 Excel-DNA 建议使用我怀疑在Winform/中使用XLL的工具WPF/控制台或Web应用程序并非易事: https://stackoverflow.com/a/2865023/495455


I gave all 3 suggestions a go but didn't have any luck. Given the author of the XLL tool Excel-DNA recommends using a tool I suspect consuming a XLL in a Winform/WPF/Console or Web app is not trivial:https://stackoverflow.com/a/2865023/495455

这篇关于从C#调用XLL文件中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 14:49