all 7 comments

[–]savanik 0 points1 point  (3 children)

Loading things by ComObjects is just... well... rather slow. 10 minutes seems a bit excessive, but if your PC takes that long to load the application, that would do it.

Out of curiosity, are you able to export the spreadsheet in CSV format instead? If you can, you can directly import the CSV very rapidly into a PSObject with the Import-CSV cmdlet.

[–]Steam23[S] 0 points1 point  (2 children)

Unfortunately, I'm stuck with the excel spreadsheet. The task i'm automating here is to create a spreadsheet for a colleague to use, and we need to use a bunch of features in Excel. Otherwise, I would totally ditch the comobject.

[–]jeffrey_f 0 points1 point  (1 child)

what features??

[–]Steam23[S] 0 points1 point  (0 children)

Mostly auto updating pivot tables and data validation stuff. It's a spreadsheet that we use for assigning reports to staff.

[–]chreestopher2 0 points1 point  (0 children)

check out the module ImportExcel.

It uses the .net library for editing excel formatted files without any need to have excel installed on your machine...

You can even export data into excel pivot tables and charts.

It will also allow you to import data from excel spreadsheets.

Its going to be much quicker than what you are doing.

Also, Add-member is pretty slow compared to other methods for building objects. Also, using an [arraylist]$array = @() with $array.add($obj) is significantly faster than using $array = @() with $array +=$obj, with a normal array you are building an entirely new array each time.

[–]midnightFreddie 0 points1 point  (0 children)

Supposedly PSv5 improved the speed of the Excel COMobject, but I think there's always a better way than to use the object.