Serving the Quantitative Finance Community

 
User avatar
player
Topic Author
Posts: 0
Joined: August 5th, 2002, 10:00 am

xll dll

July 15th, 2004, 1:22 pm

If you want to transport function from c++ into excel what is the difference in DLL and xll add in. IE when should one use one and not the other..And by transport I mean write the function in C++.net but be able to use it in excel and C++.net framework
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

xll dll

July 15th, 2004, 1:33 pm

An XLL add-in is a DLL as well, but uses the C interface. A COM DLL is using the COM interface. Which one you should use depends on the task and the Excel version. There is still a difference between a native DLL and a managed DLL (also called assembly). For an XLL interface to managed code see ManagedXLL. J.
 
User avatar
DavidJN
Posts: 270
Joined: July 14th, 2002, 3:00 am

xll dll

July 15th, 2004, 1:39 pm

An xll is a dll with added specialized functionality which allows it to be used directly in the spreadsheet via the Excel C API. Functions in an xll will appear in the Excel Function Wizard and behave like any native Excel worksheet function. Xll functions are NOT easily accessible in VBA modules or elsewhere, however.
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

xll dll

July 15th, 2004, 1:42 pm

Xll functions are NOT easily accessible in VBA modules or elsewhere, however.I consider Application.Run("YourXllFunctionHere", a, b, c) easy
 
User avatar
player
Topic Author
Posts: 0
Joined: August 5th, 2002, 10:00 am

xll dll

July 15th, 2004, 2:05 pm

Ok here comes the next question...How do I create the xll in visual C++.net framework?I'm going to file new project and then lost
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

xll dll

July 15th, 2004, 2:12 pm

See private message.
 
User avatar
DavidJN
Posts: 270
Joined: July 14th, 2002, 3:00 am

xll dll

July 15th, 2004, 5:09 pm

jens,Application.Run works but it is pretty inelegant, more like last resort brute force. Don't all arguments have to be variants (I used it so long ago I can't recall offhand)?
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

xll dll

July 15th, 2004, 9:52 pm

Application.Run works but it is pretty inelegantthat holds for VBA in general...
 
User avatar
hazerider
Posts: 0
Joined: July 24th, 2003, 3:45 pm

xll dll

July 16th, 2004, 11:46 am

As long as we're being brutish and inelegant, you can create an XLA that consists uniquely of Declare statements.
 
User avatar
mutley
Posts: 20
Joined: February 9th, 2005, 3:51 pm

xll dll

March 14th, 2006, 9:42 am

Old thread but a useful one I guess. Application.Run works with both variants and explicit types. Ugly as sin & looks like a real afterthought by the MS devs!
 
User avatar
gatechfe08
Posts: 0
Joined: January 25th, 2008, 4:31 pm

xll dll

March 8th, 2008, 3:29 pm

how do u incorporate a customised function in C++.. into MS excel through dll/xll??? i have tried everthng... doesnot work though... please help me out....tried using sample codes on net... still does not work...
 
User avatar
elektor
Posts: 0
Joined: January 18th, 2008, 8:22 am

xll dll

March 26th, 2008, 10:03 am

Hi gatechfe08,There is a nice article in codeproject.com.I have made a dll in C++ Borland with the help of the person who has written the article on codeproject.The function is to sum two integers and return the sum in a cell in excel.You need the Borland 5.5.1 compiler for this.The Code(sumtwoints.cpp)----------------------------------#define dllexport __declspec(dllexport)extern "C" {dllexport _stdcall int sum_two_integers (int first, int second) { return first + second; }}The Command line compile---------------------------------BCC32 -tWD -O2 sumtwoints.cppThe output will be a sumtwoints.dll. This should be copied into the same folder where your excel file sits.Now open VBE of Excel. Add this line in a VBA module.Public Declare Function sum_two_integers Lib "sumtwoints" (ByVal first As Long, ByVal second As Long) As LongGo to cell in workbook. and type sum_two_integers(1,2). You should be getting the results. Remember to use the latest compiler. google it.Regards
 
User avatar
PiotrW
Posts: 7
Joined: March 5th, 2004, 12:49 pm

xll dll

August 31st, 2009, 7:41 am

Hi Elektor,I have several quastions to your post, if you do not mind:1. I suppose you have to use DLL WIZARD in bcb to write "Code(sumtwoints.cpp)", right?2. Shouldn't there be any dllimport in the subsequenst statement?3. Could you explain what this "-O2" in "BCC32 -tWD -O2 sumtwoints.cpp" means?Regards,PiotrW