Grasshopper

algorithmic modeling for Rhino

Hi guys,

I tried to access excel instance with C# in Grasshopper.

I have read this article,

http://www.grasshopper3d.com/forum/topics/excel-and-gh-first-step?x...

but, it seems not working in Grasshoper v0.9.00xx (I tried, 9.0010 and 9.0014)

If I try this code

------------------------------------------------------------------------------

System.Globalization.CultureInfo oldCI = new System.Globalization.CultureInfo("en-US");

Object objExcel;

objExcel = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");

objExcel.Cells(2, 1).Value = "titleA";

------------------------------------------------------------------------------

I see, the message

" Error: 'object' does not contain a definition for 'Worksheets' (line 95) "

Line 95 is the last one code>objExcel.Cells(2, 1).Value = "titleA";  >

I've also tried,

Microsoft.Office.Interop.Excel.Application xlApp;
xlApp = (Microsoft.Office.Interop.Excel.Application) System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");

But GH C# says

Error: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) (line 89)

What did I wrong??

Views: 1034

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service