mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Replace [void] with $null
This commit is contained in:
@@ -64,7 +64,7 @@
|
|||||||
[String]$NoBlank
|
[String]$NoBlank
|
||||||
)
|
)
|
||||||
if ($Range -is [Array]) {
|
if ($Range -is [Array]) {
|
||||||
[void]$PSBoundParameters.Remove("Range")
|
$null = $PSBoundParameters.Remove("Range")
|
||||||
$Range | Add-ExcelDataValidationRule @PSBoundParameters
|
$Range | Add-ExcelDataValidationRule @PSBoundParameters
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -635,7 +635,7 @@
|
|||||||
$ColumnIndex += $InputObject.Columns.Count - 1
|
$ColumnIndex += $InputObject.Columns.Count - 1
|
||||||
if ($noHeader) {$row += $InputObject.Rows.Count -1 }
|
if ($noHeader) {$row += $InputObject.Rows.Count -1 }
|
||||||
else {$row += $InputObject.Rows.Count }
|
else {$row += $InputObject.Rows.Count }
|
||||||
[void]$PSBoundParameters.Remove('InputObject')
|
$null = $PSBoundParameters.Remove('InputObject')
|
||||||
$firstTimeThru = $false
|
$firstTimeThru = $false
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -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.
|
#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
|
$params = @{} + $PSBoundParameters
|
||||||
'Path', 'Clearsheet', 'NoHeader', 'FromLabel', 'LabelBlocks', 'HideSource',
|
'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 ($params.Keys.Count) {
|
||||||
if ($Title) { $params.StartRow = 2}
|
if ($Title) { $params.StartRow = 2}
|
||||||
$params.WorkSheetName = $WorkSheetName
|
$params.WorkSheetName = $WorkSheetName
|
||||||
|
|||||||
@@ -130,7 +130,7 @@
|
|||||||
}
|
}
|
||||||
if ($PSBoundParameters.AutoFilter -and ($PSBoundParameters.TableName -or $PSBoundParameters.TableStyle)) {
|
if ($PSBoundParameters.AutoFilter -and ($PSBoundParameters.TableName -or $PSBoundParameters.TableStyle)) {
|
||||||
Write-Warning "Tables are automatically auto-filtered, -AutoFilter will be ignored"
|
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)
|
#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
|
#If we got -MSSQLServer, create a SQL connection, if we didn't but we got -Connection create an ODBC connection
|
||||||
|
|||||||
@@ -110,7 +110,7 @@
|
|||||||
)
|
)
|
||||||
process {
|
process {
|
||||||
if ($Range -is [Array]) {
|
if ($Range -is [Array]) {
|
||||||
[void]$PSBoundParameters.Remove("Range")
|
$null = $PSBoundParameters.Remove("Range")
|
||||||
$Range | Set-ExcelRange @PSBoundParameters
|
$Range | Set-ExcelRange @PSBoundParameters
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -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
|
#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
|
$results = ((Get-Process) + (Get-Process -id $PID)) | Select-Object -last 10 -Property Name, cpu, pm, handles, StartTime
|
||||||
$DataTable = [System.Data.DataTable]::new('Test')
|
$DataTable = [System.Data.DataTable]::new('Test')
|
||||||
[void]$DataTable.Columns.Add('Name')
|
$null = $DataTable.Columns.Add('Name')
|
||||||
[void]$DataTable.Columns.Add('CPU', [double])
|
$null = $DataTable.Columns.Add('CPU', [double])
|
||||||
[void]$DataTable.Columns.Add('PM', [Long])
|
$null = $DataTable.Columns.Add('PM', [Long])
|
||||||
[void]$DataTable.Columns.Add('Handles', [Int])
|
$null = $DataTable.Columns.Add('Handles', [Int])
|
||||||
[void]$DataTable.Columns.Add('StartTime', [DateTime])
|
$null = $DataTable.Columns.Add('StartTime', [DateTime])
|
||||||
foreach ($r in $results) {
|
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 $results -WorksheetName Sheet1 -RangeName "Whole"
|
||||||
export-excel -Path $path -InputObject $DataTable -WorksheetName Sheet2 -AutoNameRange
|
export-excel -Path $path -InputObject $DataTable -WorksheetName Sheet2 -AutoNameRange
|
||||||
|
|||||||
Reference in New Issue
Block a user