hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

Run F# from Excel VBA?

Last post 07-06-2009, 22:48 by prendebp. 2 replies.
Sort Posts: Previous Next
  •  07-02-2009, 18:27 11175

    Run F# from Excel VBA?

    Do you think it would be worthwhile writing a .NET COM wrapper (tied to an F# library) that could be called from VBA/Excel Formulas? I am thinking that this would allow parallel processing within Excel VBA :-)

    My immediate concerns: (1) is the Excel/Office team already working to allow Excel VBA to do parallel processing natively? (2) would marshalling Excel ranges across to double or decimal arrays in .NET and back again be too costly in itself and make gains made via F# not worth it?

    I have a client who has a long-running VBA recursive function. I do need to discern: is it long-running just because it's recursive, or because it links to many other spreadsheets, or because it is merely crunching large amounts of data . . . as I do realize the gains of the F# COM Wrapper may depend on these details.

    Still, this is compelling to me. Any comments, thoughts, or opinions from the F# community?

    Thanks,
    Bryan

    PS I do think trading application developers might be interested. This approach reminds me of the product managedxll available at www.managedxll.com . . . but what I am proposing is much simpler and home-grown, maybe what I am proposing would best be completed as a codeplex project?
  •  07-03-2009, 8:39 11176 in reply to 11175

    Re: Run F# from Excel VBA?


    I'd steer clear of COM if you can. Try ExcelDna and/or VSTO - it's almost certainly worthwhile.

    regards,

    Danny
  •  07-06-2009, 22:48 11207 in reply to 11176

    Re: Run F# from Excel VBA?

    Thanks for the reply . . . I appreciate your feedback. That ExcelDNA looks very interesting, and may help guide me. As for VSTO, I did originally look at that but such a solution required me to maintain and deploy (and re-deploy) the code libraries.

    The interesting thing about using an F# COM wrapper is that I can then expose libraries directly to my Excel power user so that this user may continue to write and maintain his own custom VBA, but now with the power to also reference/call out to my newly exposed F# wrapper method calls.

    I already have a working barebones prototype using simple scalar values, but I need to also add support for marshalling arrays from Excel to double or decimal arrays in COM. Moreover, I need to optimize it and test whether it yields any performance gains.

    Actually, my first move may be to get my power user a multi-core PC and benchmark any potential improvement just from that; perhaps, Excel already contains some minimal support for running on multiple processors?
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems