4

I have a program which uses a DLL called spreadsheetgear.dll

In Visual Studio C# I do the following:

Reference the spreadsheetgear.dll
SpreadsheetGear.IWorkbook workbook1 =
    SpreadsheetGear.Factory.GetWorkbook("C:\text.xls");

This works fine in C# with Visual Studio

In Powershell, I create the analogous logic by:

Add-Type -Path "C:\spreadsheetgear.dll"
$workbook1 = New-Object SpreadsheetGear.Factory.GetWorkbook("c:\test.xls")

However Powershell gives me an error saying .... New-Object : Cannot find type [SpreadsheetGear.Factory.GetWorkbook]: make sure the assembly containing this type is loaded.

What am I doing wrong ... please assist.

Thank you.

1
  • Clarification - Is this powershell 1 or 2? [Reflection.Assembly]::LoadFile was required back in 1. Commented Apr 19, 2011 at 20:29

1 Answer 1

4

You are not creating a new-object - you are calling a static method. Try:

 [SpreadsheetGear.Factory]::GetWorkbook("c:\test.xls")

GetWorkbook is actually a method on the SpreadsheetGear.Factory type - the error message is quite correct.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.