Replace [void] with $null

This commit is contained in:
ili101
2019-04-08 13:34:31 +03:00
parent 52231254a5
commit 92c97b25c3
6 changed files with 11 additions and 11 deletions

View File

@@ -64,7 +64,7 @@
[String]$NoBlank
)
if ($Range -is [Array]) {
[void]$PSBoundParameters.Remove("Range")
$null = $PSBoundParameters.Remove("Range")
$Range | Add-ExcelDataValidationRule @PSBoundParameters
}
else {

View File

@@ -635,7 +635,7 @@
$ColumnIndex += $InputObject.Columns.Count - 1
if ($noHeader) {$row += $InputObject.Rows.Count -1 }
else {$row += $InputObject.Rows.Count }
[void]$PSBoundParameters.Remove('InputObject')
$null = $PSBoundParameters.Remove('InputObject')
$firstTimeThru = $false
}
#endregion

View File

@@ -198,7 +198,7 @@
#We accept a bunch of parameters work to pass on to Export-excel ( Autosize, Autofilter, boldtopRow Freeze ); if we have any of those call export-excel otherwise close the package here.
$params = @{} + $PSBoundParameters
'Path', 'Clearsheet', 'NoHeader', 'FromLabel', 'LabelBlocks', 'HideSource',
'Title', 'TitleFillPattern', 'TitleBackgroundColor', 'TitleBold', 'TitleSize' | ForEach-Object {[void]$params.Remove($_)}
'Title', 'TitleFillPattern', 'TitleBackgroundColor', 'TitleBold', 'TitleSize' | ForEach-Object {$null = $params.Remove($_)}
if ($params.Keys.Count) {
if ($Title) { $params.StartRow = 2}
$params.WorkSheetName = $WorkSheetName

View File

@@ -130,7 +130,7 @@
}
if ($PSBoundParameters.AutoFilter -and ($PSBoundParameters.TableName -or $PSBoundParameters.TableStyle)) {
Write-Warning "Tables are automatically auto-filtered, -AutoFilter will be ignored"
[void]$PSBoundParameters.Remove('AutoFilter')
$null = $PSBoundParameters.Remove('AutoFilter')
}
#We were either given a session object or a connection string (with, optionally a MSSQLServer parameter)
#If we got -MSSQLServer, create a SQL connection, if we didn't but we got -Connection create an ODBC connection

View File

@@ -110,7 +110,7 @@
)
process {
if ($Range -is [Array]) {
[void]$PSBoundParameters.Remove("Range")
$null = $PSBoundParameters.Remove("Range")
$Range | Set-ExcelRange @PSBoundParameters
}
else {

View File

@@ -5,13 +5,13 @@ Describe "Exporting with -Inputobject" {
#Read race results, and group by race name : export 1 row to get headers, leaving enough rows aboce to put in a link for each race
$results = ((Get-Process) + (Get-Process -id $PID)) | Select-Object -last 10 -Property Name, cpu, pm, handles, StartTime
$DataTable = [System.Data.DataTable]::new('Test')
[void]$DataTable.Columns.Add('Name')
[void]$DataTable.Columns.Add('CPU', [double])
[void]$DataTable.Columns.Add('PM', [Long])
[void]$DataTable.Columns.Add('Handles', [Int])
[void]$DataTable.Columns.Add('StartTime', [DateTime])
$null = $DataTable.Columns.Add('Name')
$null = $DataTable.Columns.Add('CPU', [double])
$null = $DataTable.Columns.Add('PM', [Long])
$null = $DataTable.Columns.Add('Handles', [Int])
$null = $DataTable.Columns.Add('StartTime', [DateTime])
foreach ($r in $results) {
[void]$DataTable.Rows.Add($r.name, $r.CPU, $R.PM, $r.Handles, $r.StartTime)
$null = $DataTable.Rows.Add($r.name, $r.CPU, $R.PM, $r.Handles, $r.StartTime)
}
export-excel -Path $path -InputObject $results -WorksheetName Sheet1 -RangeName "Whole"
export-excel -Path $path -InputObject $DataTable -WorksheetName Sheet2 -AutoNameRange