best way to interface D code to Excel

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 18 01:50:42 PDT 2015


On Wednesday, 17 June 2015 at 18:35:36 UTC, Laeeth Isharc wrote:
> Hi.
>
> Any thoughts on the best way to write D functions that I can 
> call from Excel?  I am completely unfamiliar with Windows 
> programming and COM (last time I wrote this kind of thing was 
> in the mid-90s I think using xloper and C).
>
> The easiest way for now seems to be via pyxll and pyd.  Wrap 
> the D function using pyd and then call it from an annotated 
> pyxll python function.  That's probably good enough for a 
> start, but it requires python to be installed on each user 
> machine which I would rather not have as the end game - just a 
> single xll would be perfect.
>
> I know D has support for COM - not sure of its status.  And 
> there was a Microsoft chap who posted here a couple of years 
> back - wonderful templated code that made it easy to write this 
> kind of thing.  Unfortunately he wasn't able to share it 
> publicly.
>
> So I would like to write:
> 1. worksheet function that will function picker and have help 
> text in the picker.  In general will take some combination of 
> strings, doubles and arrays of doubles as arguments and return 
> either string, double, or range/matrix of doubles.
> 2. vba function with similar kinds of arguments and return 
> values.
>
> I know it's easy to do this with double** and the like - at 
> least on the VBA side.  I got a bit stuck navigating the 
> headers when it comes to Excel strings.
>
> If anyone has some source they could point me to, and some 
> reading material then I would very much appreciate it.  This 
> might help facilitate adoption of D within a large financial 
> institution, but it is early days yet.  And I would guess this 
> is a common sort of use for people operating in a financial 
> environment, since people are still attached to spreadsheets.
>
> Thanks.
>
>
> Laeeth.

You want to write extensions to Excel, in D? It's not that 
pretty, but there's always the Excel C-API 
(https://msdn.microsoft.com/en-us/library/office/bb687829.aspx)

I don't know whether D's DLL support is up to the task though, 
but that's beyond my knowledge.


More information about the Digitalmars-d-learn mailing list