dfinke / ImportExcel

PowerShell module to import/export Excel spreadsheets, without Excel
https://www.powershellgallery.com/packages/ImportExcel/
Apache License 2.0
2.48k stars 400 forks source link

Is there a way to freeze top rows and/or column after a bunch of Set-ExcelRange calls? #1614

Closed kwein123 closed 4 months ago

kwein123 commented 5 months ago

Pardon me if my code style is backwards from Doug's examples. In my work, I create a custom spreadsheet from various data. After all that formatting, I would like to freeze the top two rows and first column. But if I try something like this, it errors out:

Set-ExcelRange -Worksheet $Worksheet -Address $Range -FreezeTopRow

If I try something like this at the end of my script, it doesn't error, but doesn't do anything helpful, either:

Export-Excel -ExcelPackage $Excel -FreezeTopRow
dfinke commented 5 months ago

@kwein123 thanks for using ImportExcel.

Not backwards at all. That would be a good guess and I didn't implement it that way, (unfortunately?)

You need to grab the the worksheet and then: $ws.View.FreezePanes(3, 2)

kwein123 commented 4 months ago

That worked great! Thanks for all your help.