# Excel DNA
[Excel DNA](https://excel-dna.github.io/) is a great looking library that allows you to build Excel add-ins using .NET.
## Basic Syntax
- Use the `[ExcelFunction]` and `[ExcelCommand]` attributes to designate what code should be available. It seems though that all public static functions of static classes are included as commands by default (at least that is the case with RaceCon tests).
## Strangeness with Protocol Buffers
When using this with gRPC or Protocol Buffers, make sure you include the `Google.Protobuf` Nuget package or your functions won't be properly triggered.
## Getting Started with an SDK project
All of these are seemingly unnecessary for non-SDK projects. These steps were taken from a Matthew Crews tutorial on using [ExcelDNA with F#](https://www.youtube.com/embed/SXkT-wbHR_I).
- .NET Framework is a dependency as of 1/9/2021 (v1.1.1)
- Name of nuget package is ExcelDna.AddIn
- Remove `IncludeAssets` from proje files from `PackageReference`
- Include the following `PropertyGroup`:
```xml
<PropertyGroup>
<ExcelDnaAllowPackageReferenceProjectStyle>true</ExcelDnaAllowPackageReferenceProjectStyle>
<RunExcelDnaSetDebuggerOptions>false</RunExcelDnaSetDebuggerOptions>
</PropertyGroup>
```
- Add an Excel DNA file
- Name should be \<nameOfProject\>-AddIn.dna
```xml
<DnaLibrary RuntimeVersion="v4.0">
<ExternalLibrary Path="TestLib.dll" />
</DnaLibrary>
```
- If you use `ExternalLibrary` you need to decorate functions with the `ExcelFunction` attribute
### Debugging
Need to setup Visual Studio to:
1. Start Excel
- Important to keep in mind what's your project's configuration and what verion of Excel you have installed.
- In Visual Studio, under *Debug*, instead of launching the *Project* you need to select the Excel *Exectutable* (whose path will depend on what version you have installed)
2. Add the AddIn
- You need to feed Excel the AddIn as an argument (xll file)
- Need to choose the one which corresponds to your version of Excel (and you'll find it in the folder which depends on your configuration)
3. Attach to process
- Should just work