Is returning complex data types from functions possible?

48 views
Skip to first unread message

Antonio Nakić-Alfirević

unread,
Jun 7, 2021, 8:06:43 AM6/7/21
to Excel-DNA
Excel now has support for rich data types, such as geography (or composite data types returned from PowerQuery) which allows other cells to drill into data in a cell that has a value of a complex type (e.g. population from geography):
complext_types.png

Is it possible to return a complex value that would support this from an ExcelDNA function?

Thanks,
Antonio

Govert van Drimmelen

unread,
Jun 7, 2021, 8:11:58 AM6/7/21
to exce...@googlegroups.com
Hi Antonio,

No - Excel does not support this for VBA or C API functions.

-Govert


--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/c43939f1-78af-487d-be43-d92b950d6682n%40googlegroups.com.

Antonio Nakić-Alfirević

unread,
Jun 7, 2021, 9:07:00 AM6/7/21
to exce...@googlegroups.com
Ah, too bad. I expected that was probably the case, though.

Thanks for the info, Govert

Joe Bourne

unread,
Jun 7, 2021, 9:42:19 AM6/7/21
to exce...@googlegroups.com
What I do is have the worksheet function return an ID that's the dictionary key of a C# object. 
Other worksheet functions can use this ID to retrieve the C# object from the internal dictionary and return the properties of the object.
This works well for RTD type scenarios, under the hood my RTD functions are all C# objects with lots of properties that I can selectively display using other worksheet functions. 
As an example, I have a "=Debug("A1")" array function that uses reflection to populate a range of cells with the values from a complex C# object.
hope that makes sense! :)




Reply all
Reply to author
Forward
0 new messages