mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 21:33:16 +00:00
Add helpers
This commit is contained in:
16
Public/Enable-ExcelAutoFilter.ps1
Normal file
16
Public/Enable-ExcelAutoFilter.ps1
Normal 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
|
||||||
|
}
|
||||||
16
Public/Enable-ExcelAutofit.ps1
Normal file
16
Public/Enable-ExcelAutofit.ps1
Normal 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()
|
||||||
|
}
|
||||||
15
Public/Get-ExcelSheetDimensionAddress.ps1
Normal file
15
Public/Get-ExcelSheetDimensionAddress.ps1
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user