Write excel in lunchbox

Hi all,

Hope you can help me out here. I would like to write a simple column of numbers into an excel file,
but for some reason I keep getting an error, which translates as ‘Object reference not set to an instance of an object’. There are no dots in the file path (except for extension). I have updated to the latest Lunchbox version as well (LunchBox for Grasshopper V2), but this didn’t solve it.

Any suggestions?
Thanks,

Wilco

curve length to excel2.gh (13.2 KB)

Just tested it here and it looks like the file has to exist on disk. Doesn’t have to be a valid excel file though…

EDIT: I’ve added a small C# script that creates an empty file, be careful as it doesn’t check if the file exists etc. Not sure if it breaks when the file already exists.
curve length to excel_modified.gh (11.9 KB)

Thanks, I will try this out and let you know!

Hi. A test file is made, but there is no data visible in the cells. And I get the same error in GH…

pretty sure this is not a good idea…

@wilco.spruijt

cs_writeExcel.gh (6.7 KB)
try this.
if excel is open, it uses the opened instance.
else it opens excel.
if the file exists, it opens it.
if not, a new xlsx worksheet is created and saved. (It’s way more stable when saved)

values are set into rows and colums following the tree structure at the given start cell (in string format like this: 4,3)

for headers you need to merge the headers string with your data list.

you might need to right-click on the c# element and manage assemblies. here is the dll file you might need to manage:
Microsoft.Office.Interop.Excel.rar (221.1 KB)

please note that excel extension is .xlsx rather than .xls

This should work for Excel 2010 up to now

hope this helps