In the c# script editor in GH in Rhino 7, to use the Excel Interop libary, you would add this statement:
using Microsoft.Office.Interop.Excel;
However in GH in Rhino 8, in the csharp script editor, this statement doesn’t work. In fact the the Microsoft namespace doesn’t even have Office in it.
How does one get set up to use Excel Interop in the new c# editor? I can copy the old c# script component over from older scripts and use that, but it sure would be nice to get going in the snazzy new editor!
#r "nuget: Microsoft.Office.Interop.Excel, 15.0.4795.1001"
using Microsoft.Office.Interop.Excel;
// your excel code
The Rhino 7 editor works probably because a plugin is already loading this dll. If that is the case, you can just reference that dll in your script instead on NuGet package to avoid conflicts:
// r "Microsoft.Office.Interop.Excel.dll"
using Microsoft.Office.Interop.Excel;
// your excel code
I’d forgotten that the assembly needs to be loaded first (the old way was to right-click on the c# component, the new way is to put the reference in a comment as you’re showing). I just referenced the same dll I was using before (which I assume got installed with Office 2016):
// r "C:\Program Files\Microsoft Office\root\Office16\ADDINS\Microsoft Power Query for Excel Integrated\bin\Microsoft.Office.Interop.Excel.dll"
using Microsoft.Office.Interop.Excel;