Search code examples
c#visual-studioexcel-dna

How to build XLL with Excel-DNA


I am trying to follow the simplest example at the Excel-DNA.net front page to create a simplest UDF for Excel. My code builds correctly, except it builds into dll instead of xll. How do I build it into an xll file?

I literally follow the example from the page (copy pasting it here)

  1. Create a new Class Library (.NET Framework) project in Visual Basic, C# or F#.
  2. Use the Manage NuGet Packages dialog or the Package Manager Console to install the Excel-DNA package: PM> Install-Package ExcelDna.AddIn
  3. Add your code (C#, Visual Basic.NET or F#):

using ExcelDna.Integration;

public static class MyFunctions { [ExcelFunction(Description = "My first .NET function")] public static string SayHello(string name) { return "Hello " + name; } }

  1. Compile, load and use your function in Excel:

=SayHello("World!")

All is fine, except it builds into DLL...


Solution

  • The most likely reason why your project is not creating an .xll is because the library you created is targeting ".NET Standard" and not ".NET Framework". The project file format used when targeting ".NET Standard" is not compatible with the NuGet package.

    Maybe you can check that again when creating the project, paying particular attention to the "... (.NET Framework)" vs "... (.NET Standard)" option.