3

I have downloaded the F# zipped distribution (i.e., without the installer) on Windows and I have a difficulty using ExcelDna with it.

When I copy the FSharp.Core.dll and the powerpack ones into the directory of the ExcelDna files (xxx.dna and xxx.xll), and use code into the dna file (see below), it doesn't work (although there is no error message).

<DnaLibrary Name="FSharp Sample" Language="F#">
    <![CDATA[

    namespace Foo

    module Bar =

      open ExcelDna.Integration
      let sayhello () = "Hello from F#"

      [<ExcelFunction(Category="FSharp Functions", Description="FSharp function to add numbers")>]
      let add x y = x + y

      let rec factorial = function 
        | x when (x > 1.0) -> (floor x) * factorial (x - 1.0)
        | _ -> 1.0

    ]]>
</DnaLibrary>

However it does work with the dlls in the directory, and using a reference to an F#-compiled library, as in :

<DnaLibrary>
    <ExternalLibrary Path="MyExcelDna.dll" />
</DnaLibrary>

Other languages (C# & VB) seem to work fine.

Has anyone used the ExcelDna tools with a zipped F# distribution ? Would anyone have any idea of what could be wrong ?

Many thanks for your help.

jtolle
  • 7,023
  • 2
  • 28
  • 50
123
  • 31
  • 1

2 Answers2

1

Is the Excel DNA library using CodeDOM to compile the F# code snippet?

If yes, then you'll need to make sure that the CodeDOM provider can find the fsi.exe executable (so that it can invoke it to do the compilation). By default, this uses some registry settings, so this may be a problem. You can see how the resolution works by looking at BinFolderOfDefaultFSharpCompiler in the sources in CompilerLocationUntils.fs.

Maybe adding the key fsharp-compiler-location to some app.config (not sure which one that should be though) could work.

Alternatively, you can try compiling the FSharp.Compiler.CodeDom.dll from the sources available at CodePlex and see if the CodeDom provider gets called (and with what arguments). Compiling just this single project shouldn't be difficult (it is probably easier to create new project and copy the source files there, because the project files available at CodePlex are customized and a bit confusing)

Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553
  • Yes, I think the problem comes from there. It seemed from the cod ethat it would work with other files in the same directory (fsi ...) but apparently it doesn't so... I'll stick with compiling instead of putting the code in the dna file. But thanks for your help, at least I better understand what the issue is. – 123 Dec 10 '10 at 10:35
  • The only reliable way for the CodeDom compiler to find the F# compiler is to set the FSHARP_BIN environment variable to the full path containing fsc.exe (on my machine C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\) – Govert May 19 '14 at 14:35
0

I would suggest you ask the question in one of the DNA groups: Govert (the author of ExcelDNA) is good at answering. http://groups.google.com/group/exceldna

Charles Williams
  • 23,121
  • 5
  • 38
  • 38
  • He suggested StackOverflow as he, as probably most people, is using the installer. However, I'd like to avoid having to compile the dll and cannot ask everyone to install F# & powerpack on their machine. – 123 Dec 06 '10 at 16:01