Add helpers

This commit is contained in:
dfinke
2022-04-28 19:44:49 -04:00
parent b0024cf2c4
commit eb10364722
3 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
function Enable-ExcelAutoFilter {
<#
.SYNOPSIS
Enable the Excel AutoFilter
.EXAMPLE
Enable-ExcelAutoFilter $targetSheet
#>
param(
[Parameter(Mandatory)]
[OfficeOpenXml.ExcelWorksheet]$Worksheet
)
$range = Get-ExcelSheetDimensionAddress $Worksheet
$Worksheet.Cells[$range].AutoFilter = $true
}

View File

@@ -0,0 +1,16 @@
function Enable-ExcelAutofit {
<#
.SYNOPSIS
Make all text fit the cells
.EXAMPLE
Enable-ExcelAutofit $excel.Sheet1
#>
param(
[Parameter(Mandatory)]
[OfficeOpenXml.ExcelWorksheet]$Worksheet
)
$range = Get-ExcelSheetDimensionAddress $Worksheet
$Worksheet.Cells[$range].AutoFitColumns()
}

View File

@@ -0,0 +1,15 @@
function Get-ExcelSheetDimensionAddress {
<#
.SYNOPSIS
Get the Excel address of the dimension of a sheet
.EXAMPLE
Get-ExcelSheetDimensionAddress $excel.Sheet1
#>
param(
[Parameter(Mandatory)]
[OfficeOpenXml.ExcelWorksheet]$Worksheet
)
$Worksheet.Dimension.Address
}