Added data validation

This commit is contained in:
jhoneill
2019-01-21 14:20:57 +00:00
parent 7ded24d2f9
commit 89a8cb0469
9 changed files with 258 additions and 6 deletions

View File

@@ -104,7 +104,9 @@
#Set cells to a fixed height (rows or ranges only).
[float]$Height,
#Hide a row or column (not a range); use -Hidden:$false to unhide.
[Switch]$Hidden
[Switch]$Hidden,
#Locks cells. Cells are locked by default use -locked:$false on the whole sheet and then lock specific ones, and enable protection on the sheet.
[Switch]$Locked
)
process {
if ($Range -is [Array]) {
@@ -117,8 +119,8 @@
elseif ($WorkSheet -and ($Range -is [string] -or $Range -is [OfficeOpenXml.ExcelAddress])) {
$Range = $WorkSheet.Cells[$Range]
}
elseif ($Range -is [string]) {Write-Warning -Message "The range pararameter you have specified also needs a worksheet parameter."}
elseif ($Range -is [string]) {Write-Warning -Message "The range pararameter you have specified also needs a worksheet parameter." ;return}
#else we assume Range is a range.
if ($ResetFont) {
$Range.Style.Font.Color.SetColor( ([System.Drawing.Color]::Black))
$Range.Style.Font.Bold = $false
@@ -241,6 +243,9 @@
$Range -is [OfficeOpenXml.ExcelColumn] ) {$Range.Hidden = [boolean]$Hidden}
else {Write-Warning -Message ("Can hide a row or a column but not a {0} object" -f ($Range.GetType().name)) }
}
if ($PSBoundParameters.ContainsKey('Locked')) {
$Range.Style.Locked=$Locked
}
}
}
}