Using Excel Functions (Evaluate)

Add-in Express™ Support Service
That's what is more important than anything else

Using Excel Functions (Evaluate)
XLL with VB 
Mohammad Yamin




Posts: 5
Joined: 2022-04-18
Hi,
I am new to Add-in Express. I am used to VBA but found the Add-in Express with the VB.NET very useful and powerful. However, I need to spend time learning the basics here. Most of my project is UDF's with XLL. Would it be possible to call the Excel functions like the sum, average, ... or the evaluate statement to evaluate for example "3+5/2" or "2*sin(pi())-1"?
In other words, how can I use ADXXLLModule.CallWorksheetFunction method mentioned in the documentation?

Your suggestions are highly appreciated.

Thanks,
Mohammad
Posted 19 Apr, 2022 11:32:14 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Mohammad,

Although this is possible to do with XLL, I suppose you are looking for Excel Automation Add-in, correct? Check section What Excel UDF type to choose; see the PDF file in the folder {Add-in Express}\Docs on your development PC.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Apr, 2022 03:49:44 Top
Mohammad Yamin




Posts: 5
Joined: 2022-04-18
I thought the XLL is the one for faster computations! I reviewed the difference and I feel the XLL is the one I need for this part of the project that performs computations based on the user's inputs (I will need the COM addin for ribbon later). I wanted to know how to access the Excel functions to help with the computations within the UDFs. I tried the CallWorksheetFunction and it worked successfully (Yay). Two questions came to my mind based on your reply and my review of the documentation:
1- Do you recommend the use of COM addin and add an XLL module, and later I can easily add a ribbon when needed? or create XLL addin and later add a COM addin to the XLL addin to create a ribbon? Does it matter?

2- Would it be possible with the Add-in Express (the XLL addin) to show descriptions of the UDF's arguments in real-time while the user is typing the function in the spreadsheet (not the formula bar) like the native Excel functions? (once you type Sum(, Excel will show a tooltip with number1, number2, etc...)

Thanks again for your reply!
Mohammad
Posted 20 Apr, 2022 10:27:28 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Mohammad,

If XLL is right for you, then it is okay. Note however that the fastest possible computations require writing your add-in in native C++. Our estimate is: the .NET code is some 20% slower than its native code equivalent. This is due to the need to transfer data between managed and unmanaged memory.

Mohammad Yamin writes:
Does it matter?


It doesn't.

Mohammad Yamin writes:
2- Would it be possible with the Add-in Express (the XLL addin) to show descriptions


Add-in Express doesn't show descriptions; this is Excel who does this.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 21 Apr, 2022 03:44:11 Top
Mohammad Yamin




Posts: 5
Joined: 2022-04-18
Thanks for the reply! Any plans for Addin Express to allow the showing of UDF description while typing in the spreadsheet? (I remember you mentioned in one of the forums the ExcelDNA; I just found that the ExcelDNA can show the descriptions When I checked it)
I am in the engineering field and showing descriptions is very useful/essential. I wish the Addin Express would be willing to consider this improvement.

Thanks,
Mohammad
Posted 25 Apr, 2022 10:02:37 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Mohammad,

Mohammad Yamin writes:
Any plans for Addin Express to allow the showing of UDF description


Alas, no such plans at the moment.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 25 Apr, 2022 11:15:42 Top
Mohammad Yamin




Posts: 5
Joined: 2022-04-18
Thank you, Andrei! I am guessing it is not an easy thing to do or not worth the time to invest in.
Please share if you come across any article/advice related to this. Thanks again!

Mohammad
Posted 26 Apr, 2022 11:05:17 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Mohammad,

As far as I remember Govert - the creator of Excel DNA - published his idea of getting/showing descriptions. Sorry, I don't remember details. I have an impression he also published the source code.

I would suggest creating a pane. Your COM add-in might detect your function(s) in the selected cell and show the pane populating its controls with data from the selected cell and meta-information available for the COM add-in.

There's an example at https://www.add-in-express.com/creating-addins-blog/2011/10/11/invoke-excel-addin-xll/. Although it is not directly applicable, it demonstrates - I believe - some useful ideas.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 26 Apr, 2022 12:00:28 Top
Mohammad Yamin




Posts: 5
Joined: 2022-04-18
Hello Andrei,
I was just reading one of the forums and noticed that you suggested in your answer the solution that combining the ExcelDNA and Addin Express would be a viable option. How would that be possible? could you elaborate on this more or give example? that would be greatly appreciated.

Thanks,
Mohammad
Posted 26 Apr, 2022 13:16:30 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Mohammad,

I can't tell. I've never used Excel DNA. I don't have a basic understanding of it. I suppose I was saying something of this sort: a COM add-in can communicate to an XLL by calling a hidden function; an XLL can communicate to an Add-in Express based COM add-in by calling a function declared on the add-in module.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 27 Apr, 2022 04:41:09 Top