Vollständige Version anzeigen : c# interop ListObjects

31.12.2017, 09:07

I hope I am at the right address.

I wish to access the Listobjects of a sheet using c# and excel interop.

I am porting from Powershell so I know that the Com interface is working.
However, my c# (and vscode) experience is about a days worth.

Some code:

Microsoft.Office.Interop.Excel.Worksheet excelSheet = (Microsoft.Office.Interop.Excel.Worksheet)excelDocument.Worksheets[SheetName] ;

WriteLine(excelSheet.Name); //This works as intended
WriteLine(excelSheet.ListObjects.Count) ; // Not Working: Any Collection Returned is 0

My question is why any Collection with a count member returns 0 and whether I have to take care using the proper library versions and whatnot.

Best Regards

01.01.2018, 08:40
It appears that my lack of c# knowledge is vast.

I did compile in dotnetcore2.0 as suggestet by the first tutorial I came accross.
This will lead to the creation of a dll which is unable to access listobjects.

Compiling using 471 and thus creating an exe solves the problem.

No idea why though.