We help IT Professionals succeed at work.

Powershell and Excel Formating - Freeze Pane, Merge Cells, and limit a column width

Ok,

I need someone with Powershell ability to provide me three code exmaples:

1) "Freeze Pane" hoizontally from a specific row

[This is the excel functionality that allows you to scroll the sheet without the part above it moving.]

2) "Merge Cells" from one cell to another.

[This is the excel functionality that allows you to view a large amount of text in a cell across multiple cells without anything in them.]

3) Make a column a specific width

Help!
Comment
Watch Question

try the out-grid cmdlet which was introduced in powershell v 2. it gives you nearly the same features

Follow the below article that demonstrate out-grid features

http://www.microsoft.com/technet/scriptcenter/topics/winpsh/gridview.mspx





Author

Commented:
Nope,

That's not gonna work... I've already got the sucker completely built in Excel... I just need to answer the three issues above...

Commented:
For column width...
if you have your cells or range selected in a variable
$range.columnwidth = 75

I will see if I can do anything for the other 2

Author

Commented:
Anyone?

I'm working with Excel here...

I need to figure out how to, in code, tell Excel (using powershell) to "freeze and area" with I under is called Freeze Pane in Excel
Commented:
And to merge...
Save your range to a variable

$Selection = $wSheet.Range("A1:A6")
$Selection.Merge()

Open in new window

Commented:
And finally... how to use Freezepanes

$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$wSheet = $Excel.Worksheets.Item(1)
$wSheet.Cells.item(1,1) = "Group Name:"
$wsheet.application.activewindow.splitcolumn = 0
$wsheet.application.activewindow.splitrow = 1
$wsheet.application.activewindow.freezepanes = $true

Open in new window

Commented:
Glad I could help!