This is an open source project that lets you create native (.xll) add-ins for Excel using C#, VB.Net or F#.
The advantage of an XLL add-in is that it can contain high performance user-defined functions, custom ribbon interfaces plus more and requires no installation or registration and therefore working in reduced privilege environments.
The C API is not directly accessible from .NET code but the Excel-DNA runtime allows managed assemblies to integrate with the C API.

Has a NuGet Package
This creates a class library

Worksheet Functions

You are able to define the function wizard category as well as the function description and argument descriptions.
In Excel-DNA this is made possible by adding .NET attributes to the function declarations.

Other Supported Features

Multi-threaded recalculation
RTD Servers
Custom Task Panes
Integration with VBA code

The Excel-DNA runtime contains a small loader (the .XLL) that loads the .NET runtime, then checks the configuration (.dna) file and accordingly loads the managed assembly.
The managed assemblies are then inspected using the .NET Reflection API and the appropriate methods are registered.

Create Basic Add-in

This consists of three files:
1) The managed assembly MyCSharpCode.dll
2) The Excel-DNA runtime library. Distributed as exceldna.xll but renamed to MyFirstAddin.xll
3) A configuration file which is a text-based XML file renamed to MyFirstAddin.dna which contains the following:

<DnaLibrary Name="My First AddIn" RuntimeVersion="v4.0" > 
   <ExternalLibrary Path="MyCSharpCode.dll"/>

using ExcelDna.Integration 

namespace MyNewXLL
   public class MyClass
      public static string MyFunction([ExcelArgument(Description=@"Text Value")] string sText)
         return sText + sText;

AutoOpen and AutoClose

These methods will be called when your add-in is loaded and unloaded from the Excel Add-ins dialog box

public class MyAddin : ExcelDna.Integration.IExcelAddIn 
   public void AutoOpen()
   public void AutoClose()

< DnaLibrary Name="MyXLL" 
      Language="C#" <
< ExternalLibrary Path="MyXLL.dll"
      LoadFromBytes = false
      Pack = "true" <

Need to add a registry key
HKCU\Software\Microsoft\Office\12.0\Excel\Options\ OPEN1 - /R "MyXLL.dll"
If the add-in is not in the default add-ins folder then the full path must be provided

Search for OPEN[n] key
Use a custom action to loop through the keys

Does it need to be shimmed ?

Single File

Excel-DNA also contains a special packing feature that allows you to create a single xll file containing all the necessary files.



© 2018 Better Solutions Limited. All Rights Reserved. © 2018 Better Solutions Limited TopPrevNext