title: Creating new Excel formulas/functions with C#
body: <p>We are looking to be able to programmatically create an Excel workbook which would call custom code from within a cell.  Cells would look something like:</p>
  
  <pre><code>=MyCode(A1:A10)
  </code></pre>
  
  <p>My first thought was to use VBA, but since the algorithm is proprietary the powers that be want it to be protected.  I can put a password on it, but it is well documented (here on StackOverflow) on how to get around such passwords.</p>
  
  <p>My second thought was to create an Excel 2013 Workbook project in Visual Studio, but I haven't found anything useful on how to expose a function in C# so it can be called like I described.</p>
  
  <p>Next I thought about having VBA call the C#, and found instructions at <a href="https://msdn.microsoft.com/en-us/library/bb608613.aspx" rel="noreferrer">https://msdn.microsoft.com/en-us/library/bb608613.aspx</a>.  I followed those instructions to the letter, but when I try to run the VBA code I get an error with the GetManagedClass function: Object Library Feature not Supported.</p>
  
  <p>Are there any good references on how to do something like this?</p>