Remove-FreePane.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function Remove-FreezePane {
    <#
    .SYNOPSIS
        Remove FreezePanes on a specified worksheet
     
    .DESCRIPTION
        Remove FreezePanes on a specified worksheet
 
    .PARAMETER Worksheet
        Worksheet to remove FreezePanes from
 
    .PARAMETER Passthru
        If specified, pass the Worksheet back
 
    .EXAMPLE
        $WorkSheet | Remove-FreezePane
 
        # Remove frozen panes on $WorkSheet
         
    .NOTES
        Thanks to Doug Finke for his example:
            https://github.com/dfinke/ImportExcel/blob/master/ImportExcel.psm1
 
        Thanks to Philip Thompson for an expansive set of examples on working with EPPlus in PowerShell:
            https://excelpslib.codeplex.com/
 
    .LINK
        https://github.com/RamblingCookieMonster/PSExcel
 
    .FUNCTIONALITY
        Excel
    #>

    [OutputType([OfficeOpenXml.ExcelWorksheet])]
    [cmdletbinding()]
    param(
        [parameter( Mandatory=$true,
                    ValueFromPipeline=$true,
                    ValueFromPipelineByPropertyName=$true)]
        [OfficeOpenXml.ExcelWorksheet]$WorkSheet,

        [switch]$Passthru
    )
    Process
    {
        $WorkSheet.View.UnFreezePanes()
        if($Passthru)
        {
            $WorkSheet
        }        
    }
}