Merge pull request #875 from MikeyBronowski/VariableCasing

Variable casing
This commit is contained in:
Doug Finke
2020-06-26 19:30:00 -04:00
committed by GitHub
27 changed files with 98 additions and 98 deletions

View File

@@ -7,7 +7,7 @@
[OfficeOpenXml.ExcelAddressBase] [OfficeOpenXml.ExcelAddressBase]
$Address, $Address,
$ExcelPackage, $ExcelPackage,
$SourceWorkSheet, $SourceWorksheet,
$SourceRange, $SourceRange,
$PivotRows, $PivotRows,
$PivotData, $PivotData,
@@ -75,11 +75,11 @@
if (-not $wsPivot.PivotTables[$pivotTableName] ) { if (-not $wsPivot.PivotTables[$pivotTableName] ) {
try { try {
#Accept a string or a worksheet object as $SourceWorksheet - we don't need a worksheet if we have a Rangebase . #Accept a string or a worksheet object as $SourceWorksheet - we don't need a worksheet if we have a Rangebase .
if ( $SourceWorkSheet -is [string]) { if ( $SourceWorksheet -is [string]) {
$SourceWorkSheet = $ExcelPackage.Workbook.Worksheets.where( {$_.name -Like $SourceWorkSheet})[0] $SourceWorksheet = $ExcelPackage.Workbook.Worksheets.where( {$_.name -Like $SourceWorksheet})[0]
} }
elseif ( $SourceWorkSheet -is [int] ) { elseif ( $SourceWorksheet -is [int] ) {
$SourceWorkSheet = $ExcelPackage.Workbook.Worksheets[$SourceWorkSheet] $SourceWorksheet = $ExcelPackage.Workbook.Worksheets[$SourceWorksheet]
} }
if ( $SourceRange -is [OfficeOpenXml.Table.ExcelTable]) {$SourceRange = $SourceRange.Address } if ( $SourceRange -is [OfficeOpenXml.Table.ExcelTable]) {$SourceRange = $SourceRange.Address }
if ( $sourceRange -is [OfficeOpenXml.ExcelRange] -or if ( $sourceRange -is [OfficeOpenXml.ExcelRange] -or
@@ -87,13 +87,13 @@
$pivotTable = $wsPivot.PivotTables.Add($Address, $SourceRange, $pivotTableName) $pivotTable = $wsPivot.PivotTables.Add($Address, $SourceRange, $pivotTableName)
} }
elseif (-not $SourceRange) { elseif (-not $SourceRange) {
$pivotTable = $wsPivot.PivotTables.Add($Address, $SourceWorkSheet.cells[$SourceWorkSheet.Dimension.Address], $pivotTableName) $pivotTable = $wsPivot.PivotTables.Add($Address, $SourceWorksheet.cells[$SourceWorksheet.Dimension.Address], $pivotTableName)
} }
elseif ($SourceWorkSheet -isnot [OfficeOpenXml.ExcelWorksheet] ) { elseif ($SourceWorksheet -isnot [OfficeOpenXml.ExcelWorksheet] ) {
Write-Warning -Message "Could not find source Worksheet for pivot-table '$pivotTableName'." ; return Write-Warning -Message "Could not find source Worksheet for pivot-table '$pivotTableName'." ; return
} }
elseif ( $SourceRange -is [String] -or $SourceRange -is [OfficeOpenXml.ExcelAddress]) { elseif ( $SourceRange -is [String] -or $SourceRange -is [OfficeOpenXml.ExcelAddress]) {
$pivotTable = $wsPivot.PivotTables.Add($Address, $SourceWorkSheet.Cells[$SourceRange], $pivotTableName) $pivotTable = $wsPivot.PivotTables.Add($Address, $SourceWorksheet.Cells[$SourceRange], $pivotTableName)
} }
else {Write-warning "Could not create a PivotTable with the Source Range provided."; return} else {Write-warning "Could not create a PivotTable with the Source Range provided."; return}
foreach ($row in $PivotRows) { foreach ($row in $PivotRows) {
@@ -150,8 +150,8 @@
else { else {
Write-Warning -Message "PivotTable defined in $($pivotTableName) already exists, only the data range will be changed." Write-Warning -Message "PivotTable defined in $($pivotTableName) already exists, only the data range will be changed."
$pivotTable = $wsPivot.PivotTables[$pivotTableName] $pivotTable = $wsPivot.PivotTables[$pivotTableName]
if (-not $SourceRange) { $SourceRange = $SourceWorkSheet.Dimension.Address} if (-not $SourceRange) { $SourceRange = $SourceWorksheet.Dimension.Address}
$pivotTable.CacheDefinition.SourceRange = $SourceWorkSheet.cells[$SourceRange] $pivotTable.CacheDefinition.SourceRange = $SourceWorksheet.cells[$SourceRange]
#change for epPlus 4.5 - Previously needed to hack the xml #change for epPlus 4.5 - Previously needed to hack the xml
# $pivotTable.CacheDefinition.CacheDefinitionXml.pivotCacheDefinition.cacheSource.worksheetSource.ref = $SourceRange # $pivotTable.CacheDefinition.CacheDefinitionXml.pivotCacheDefinition.cacheSource.worksheetSource.ref = $SourceRange

View File

@@ -4,7 +4,7 @@ function Add-Worksheet {
param( param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = "Package", Position = 0)] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = "Package", Position = 0)]
[OfficeOpenXml.ExcelPackage]$ExcelPackage, [OfficeOpenXml.ExcelPackage]$ExcelPackage,
[Parameter(Mandatory = $true, ParameterSetName = "WorkBook")] [Parameter(Mandatory = $true, ParameterSetName = "Workbook")]
[OfficeOpenXml.ExcelWorkbook]$ExcelWorkbook, [OfficeOpenXml.ExcelWorkbook]$ExcelWorkbook,
[string]$WorksheetName , [string]$WorksheetName ,
[switch]$ClearSheet, [switch]$ClearSheet,

View File

@@ -40,7 +40,7 @@ $worksheetName = 'Processes'
$Path = "$pwd\demo.xlsx" $Path = "$pwd\demo.xlsx"
$myData = Get-Process | Select-Object -Property Name,WS,CPU,Description,company,startTime $myData = Get-Process | Select-Object -Property Name,WS,CPU,Description,company,startTime
$excelPackage = $myData | Export-Excel -KillExcel -Path $Path -WorkSheetname $worksheetName -ClearSheet -AutoSize -AutoFilter -BoldTopRow -FreezeTopRow -PassThru $excelPackage = $myData | Export-Excel -KillExcel -Path $Path -WorksheetName $worksheetName -ClearSheet -AutoSize -AutoFilter -BoldTopRow -FreezeTopRow -PassThru
$worksheet = $excelPackage.Workbook.Worksheets[$worksheetName] $worksheet = $excelPackage.Workbook.Worksheets[$worksheetName]
$range = $worksheet.Dimension.Address $range = $worksheet.Dimension.Address
Set-ExcelRange -Worksheet $worksheet -Range "b:b" -NumberFormat "#,###" -AutoFit Set-ExcelRange -Worksheet $worksheet -Range "b:b" -NumberFormat "#,###" -AutoFit

View File

@@ -13,7 +13,7 @@ Reads data from a sheet, and for each row, calls a custom scriptblock with a lis
## SYNTAX ## SYNTAX
``` ```
ConvertFrom-ExcelData [-Path] <Object> [[-scriptBlock] <ScriptBlock>] [[-WorkSheetname] <Object>] ConvertFrom-ExcelData [-Path] <Object> [[-ScriptBlock] <ScriptBlock>] [[-WorksheetName] <Object>]
[[-HeaderRow] <Int32>] [[-Header] <String[]>] [-NoHeader] [-DataOnly] [<CommonParameters>] [[-HeaderRow] <Int32>] [[-Header] <String[]>] [-NoHeader] [-DataOnly] [<CommonParameters>]
``` ```
@@ -59,8 +59,8 @@ Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -scriptBlock ### -ScriptBlock
{{ Fill scriptBlock Description }} {{ Fill ScriptBlock Description }}
```yaml ```yaml
Type: ScriptBlock Type: ScriptBlock
@@ -74,8 +74,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -WorkSheetname ### -WorksheetName
{{ Fill WorkSheetname Description }} {{ Fill WorksheetName Description }}
```yaml ```yaml
Type: Object Type: Object

View File

@@ -5,7 +5,7 @@ function ConvertFrom-ExcelData {
[Parameter(ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true, Mandatory = $true)] [Parameter(ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true, Mandatory = $true)]
[ValidateScript( { Test-Path $_ -PathType Leaf })] [ValidateScript( { Test-Path $_ -PathType Leaf })]
$Path, $Path,
[ScriptBlock]$scriptBlock, [ScriptBlock]$ScriptBlock,
[Alias("Sheet")] [Alias("Sheet")]
$WorksheetName = 1, $WorksheetName = 1,
[int]$HeaderRow = 1, [int]$HeaderRow = 1,
@@ -14,7 +14,7 @@ function ConvertFrom-ExcelData {
[switch]$DataOnly [switch]$DataOnly
) )
$null = $PSBoundParameters.Remove('scriptBlock') $null = $PSBoundParameters.Remove('ScriptBlock')
$params = @{} + $PSBoundParameters $params = @{} + $PSBoundParameters
$data = Import-Excel @params $data = Import-Excel @params
@@ -24,6 +24,6 @@ function ConvertFrom-ExcelData {
Select-Object -ExpandProperty name Select-Object -ExpandProperty name
foreach ($record in $data) { foreach ($record in $data) {
& $scriptBlock $PropertyNames $record & $ScriptBlock $PropertyNames $record
} }
} }

View File

@@ -16,12 +16,12 @@ function ConvertFrom-ExcelToSQLInsert {
[switch]$NoHeader, [switch]$NoHeader,
[switch]$DataOnly, [switch]$DataOnly,
[switch]$ConvertEmptyStringsToNull, [switch]$ConvertEmptyStringsToNull,
[switch]$UseMSSQLSyntax [switch]$UseMsSqlSyntax
) )
$null = $PSBoundParameters.Remove('TableName') $null = $PSBoundParameters.Remove('TableName')
$null = $PSBoundParameters.Remove('ConvertEmptyStringsToNull') $null = $PSBoundParameters.Remove('ConvertEmptyStringsToNull')
$null = $PSBoundParameters.Remove('UseMSSQLSyntax') $null = $PSBoundParameters.Remove('UseMsSqlSyntax')
$params = @{} + $PSBoundParameters $params = @{} + $PSBoundParameters
@@ -29,7 +29,7 @@ function ConvertFrom-ExcelToSQLInsert {
param($propertyNames, $record) param($propertyNames, $record)
$ColumnNames = "'" + ($PropertyNames -join "', '") + "'" $ColumnNames = "'" + ($PropertyNames -join "', '") + "'"
if($UseMSSQLSyntax) { if($UseMsSqlSyntax) {
$ColumnNames = "[" + ($PropertyNames -join "], [") + "]" $ColumnNames = "[" + ($PropertyNames -join "], [") + "]"
} }

View File

@@ -4,7 +4,7 @@
[Parameter(Mandatory = $true,ValueFromPipeline=$true)] [Parameter(Mandatory = $true,ValueFromPipeline=$true)]
[Alias('SourceWorkbook')] [Alias('SourceWorkbook')]
$SourceObject, $SourceObject,
$SourceWorkSheet = 1 , $SourceWorksheet = 1 ,
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
$DestinationWorkbook, $DestinationWorkbook,
$DestinationWorksheet, $DestinationWorksheet,
@@ -39,7 +39,7 @@
return return
} }
else { else {
$null = Add-Worksheet -ExcelPackage $excel -WorkSheetname $DestinationWorksheet -CopySource ($excel.Workbook.Worksheets[$SourceWorkSheet]) $null = Add-Worksheet -ExcelPackage $excel -WorksheetName $DestinationWorksheet -CopySource ($excel.Workbook.Worksheets[$SourceWorksheet])
Close-ExcelPackage -ExcelPackage $excel -Show:$Show Close-ExcelPackage -ExcelPackage $excel -Show:$Show
return return
} }
@@ -47,15 +47,15 @@
} }
else { else {
if ($SourceObject -is [OfficeOpenXml.ExcelWorksheet]) {$sourceWs = $SourceObject} if ($SourceObject -is [OfficeOpenXml.ExcelWorksheet]) {$sourceWs = $SourceObject}
elseif ($SourceObject -is [OfficeOpenXml.ExcelWorkbook]) {$sourceWs = $SourceObject.Worksheets[$SourceWorkSheet]} elseif ($SourceObject -is [OfficeOpenXml.ExcelWorkbook]) {$sourceWs = $SourceObject.Worksheets[$SourceWorksheet]}
elseif ($SourceObject -is [OfficeOpenXml.ExcelPackage] ) {$sourceWs = $SourceObject.Workbook.Worksheets[$SourceWorkSheet]} elseif ($SourceObject -is [OfficeOpenXml.ExcelPackage] ) {$sourceWs = $SourceObject.Workbook.Worksheets[$SourceWorksheet]}
else { else {
$SourceObject = (Resolve-Path $SourceObject).ProviderPath $SourceObject = (Resolve-Path $SourceObject).ProviderPath
try { try {
Write-Verbose "Opening worksheet '$WorksheetName' in Excel workbook '$SourceObject'." Write-Verbose "Opening worksheet '$WorksheetName' in Excel workbook '$SourceObject'."
$stream = New-Object -TypeName System.IO.FileStream -ArgumentList $SourceObject, 'Open', 'Read' , 'ReadWrite' $stream = New-Object -TypeName System.IO.FileStream -ArgumentList $SourceObject, 'Open', 'Read' , 'ReadWrite'
$package1 = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream $package1 = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream
$sourceWs = $Package1.Workbook.Worksheets[$SourceWorkSheet] $sourceWs = $Package1.Workbook.Worksheets[$SourceWorksheet]
} }
catch {Write-Warning -Message "Could not open $SourceObject - the error was '$($_.exception.message)' " ; return} catch {Write-Warning -Message "Could not open $SourceObject - the error was '$($_.exception.message)' " ; return}
} }
@@ -76,7 +76,7 @@
$DestinationWorkbook.Worksheets.Delete($DestinationWorksheet) $DestinationWorkbook.Worksheets.Delete($DestinationWorksheet)
} }
Write-Verbose "Copying '$($sourcews.name)' from $($SourceObject) to '$($DestinationWorksheet)' in $($PSBoundParameters['DestinationWorkbook'])" Write-Verbose "Copying '$($sourcews.name)' from $($SourceObject) to '$($DestinationWorksheet)' in $($PSBoundParameters['DestinationWorkbook'])"
$null = Add-Worksheet -ExcelWorkbook $DestinationWorkbook -WorkSheetname $DestinationWorksheet -CopySource $sourceWs $null = Add-Worksheet -ExcelWorkbook $DestinationWorkbook -WorksheetName $DestinationWorksheet -CopySource $sourceWs
#Leave the destination open but close the source - if we're copying more than one sheet we'll re-open it and live with the inefficiency #Leave the destination open but close the source - if we're copying more than one sheet we'll re-open it and live with the inefficiency
if ($stream) {$stream.Close() } if ($stream) {$stream.Close() }
if ($package1) {Close-ExcelPackage -ExcelPackage $package1 -NoSave } if ($package1) {Close-ExcelPackage -ExcelPackage $package1 -NoSave }

View File

@@ -435,8 +435,8 @@
$params = $item.value $params = $item.value
if ($Activate) {$params.Activate = $true } if ($Activate) {$params.Activate = $true }
if ($params.keys -notcontains 'SourceRange' -and if ($params.keys -notcontains 'SourceRange' -and
($params.Keys -notcontains 'SourceWorkSheet' -or $params.SourceWorkSheet -eq $WorksheetName)) {$params.SourceRange = $dataRange} ($params.Keys -notcontains 'SourceWorksheet' -or $params.SourceWorksheet -eq $WorksheetName)) {$params.SourceRange = $dataRange}
if ($params.Keys -notcontains 'SourceWorkSheet') {$params.SourceWorkSheet = $ws } if ($params.Keys -notcontains 'SourceWorksheet') {$params.SourceWorksheet = $ws }
if ($params.Keys -notcontains 'NoTotalsInPivot' -and $NoTotalsInPivot ) {$params.PivotTotals = 'None'} if ($params.Keys -notcontains 'NoTotalsInPivot' -and $NoTotalsInPivot ) {$params.PivotTotals = 'None'}
if ($params.Keys -notcontains 'PivotTotals' -and $PivotTotals ) {$params.PivotTotals = $PivotTotals} if ($params.Keys -notcontains 'PivotTotals' -and $PivotTotals ) {$params.PivotTotals = $PivotTotals}
if ($params.Keys -notcontains 'PivotDataToColumn' -and $PivotDataToColumn) {$params.PivotDataToColumn = $true} if ($params.Keys -notcontains 'PivotDataToColumn' -and $PivotDataToColumn) {$params.PivotDataToColumn = $true}
@@ -471,7 +471,7 @@
if ($ShowPercent) {$params.ShowPercent = $true} if ($ShowPercent) {$params.ShowPercent = $true}
if ($NoLegend) {$params.NoLegend = $true} if ($NoLegend) {$params.NoLegend = $true}
} }
Add-PivotTable -ExcelPackage $pkg -SourceWorkSheet $ws @params Add-PivotTable -ExcelPackage $pkg -SourceWorksheet $ws @params
} }
try { try {
@@ -544,7 +544,7 @@
foreach ($Sheet in $HideSheet) { foreach ($Sheet in $HideSheet) {
try { try {
$pkg.Workbook.WorkSheets.Where({$_.Name -like $sheet}) | ForEach-Object { $pkg.Workbook.Worksheets.Where({$_.Name -like $sheet}) | ForEach-Object {
$_.Hidden = 'Hidden' $_.Hidden = 'Hidden'
Write-verbose -Message "Sheet '$($_.Name)' Hidden." Write-verbose -Message "Sheet '$($_.Name)' Hidden."
} }
@@ -553,7 +553,7 @@
} }
foreach ($Sheet in $UnHideSheet) { foreach ($Sheet in $UnHideSheet) {
try { try {
$pkg.Workbook.WorkSheets.Where({$_.Name -like $sheet}) | ForEach-Object { $pkg.Workbook.Worksheets.Where({$_.Name -like $sheet}) | ForEach-Object {
$_.Hidden = 'Visible' $_.Hidden = 'Visible'
Write-verbose -Message "Sheet '$($_.Name)' shown" Write-verbose -Message "Sheet '$($_.Name)' shown"
} }

View File

@@ -13,7 +13,7 @@ schema: 2.0.0
## SYNTAX ## SYNTAX
``` ```
Get-ExcelColumnName [[-columnNumber] <Object>] [<CommonParameters>] Get-ExcelColumnName [[-ColumnNumber] <Object>] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -30,8 +30,8 @@ PS C:\> {{ Add example code here }}
## PARAMETERS ## PARAMETERS
### -columnNumber ### -ColumnNumber
{{ Fill columnNumber Description }} {{ Fill ColumnNumber Description }}
```yaml ```yaml
Type: Object Type: Object

View File

@@ -1,11 +1,11 @@
function Get-ExcelColumnName { function Get-ExcelColumnName {
param( param(
[Parameter(ValueFromPipeline=$true)] [Parameter(ValueFromPipeline=$true)]
$columnNumber=1 $ColumnNumber=1
) )
Process { Process {
$dividend = $columnNumber $dividend = $ColumnNumber
$columnName = New-Object System.Collections.ArrayList($null) $columnName = New-Object System.Collections.ArrayList($null)
while($dividend -gt 0) { while($dividend -gt 0) {
@@ -19,7 +19,7 @@ function Get-ExcelColumnName {
} }
[PSCustomObject] @{ [PSCustomObject] @{
ColumnNumber = $columnNumber ColumnNumber = $ColumnNumber
ColumnName = $columnName -join '' ColumnName = $columnName -join ''
} }

View File

@@ -13,7 +13,7 @@ schema: 2.0.0
## SYNTAX ## SYNTAX
``` ```
Get-HtmlTable [-url] <Object> [[-tableIndex] <Object>] [[-Header] <Object>] [[-FirstDataRow] <Int32>] Get-HtmlTable [-Url] <Object> [[-TableIndex] <Object>] [[-Header] <Object>] [[-FirstDataRow] <Int32>]
[-UseDefaultCredentials] [<CommonParameters>] [-UseDefaultCredentials] [<CommonParameters>]
``` ```
@@ -76,8 +76,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -tableIndex ### -TableIndex
{{ Fill tableIndex Description }} {{ Fill TableIndex Description }}
```yaml ```yaml
Type: Object Type: Object
@@ -91,8 +91,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -url ### -Url
{{ Fill url Description }} {{ Fill Url Description }}
```yaml ```yaml
Type: Object Type: Object

View File

@@ -3,16 +3,16 @@
function Get-HtmlTable { function Get-HtmlTable {
param( param(
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
$url, $Url,
$tableIndex=0, $TableIndex=0,
$Header, $Header,
[int]$FirstDataRow=0, [int]$FirstDataRow=0,
[Switch]$UseDefaultCredentials [Switch]$UseDefaultCredentials
) )
$r = Invoke-WebRequest $url -UseDefaultCredentials: $UseDefaultCredentials $r = Invoke-WebRequest $Url -UseDefaultCredentials: $UseDefaultCredentials
$table = $r.ParsedHtml.getElementsByTagName("table")[$tableIndex] $table = $r.ParsedHtml.getElementsByTagName("table")[$TableIndex]
$propertyNames=$Header $propertyNames=$Header
$totalRows=@($table.rows).count $totalRows=@($table.rows).count

View File

@@ -13,7 +13,7 @@ schema: 2.0.0
## SYNTAX ## SYNTAX
``` ```
Get-Range [[-start] <Object>] [[-stop] <Object>] [[-step] <Object>] Get-Range [[-Start] <Object>] [[-Stop] <Object>] [[-Step] <Object>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -45,8 +45,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -step ### -Step
{{ Fill step Description }} {{ Fill Step Description }}
```yaml ```yaml
Type: Object Type: Object

View File

@@ -1,5 +1,5 @@
function Get-Range { function Get-Range {
[CmdletBinding()] [CmdletBinding()]
param($start=0,$stop,$step=1) param($Start=0,$Stop,$Step=1)
for ($idx = $start; $idx -lt $stop; $idx+=$step) {$idx} for ($idx = $Start; $idx -lt $Stop; $idx+=$Step) {$idx}
} }

View File

@@ -13,7 +13,7 @@ schema: 2.0.0
## SYNTAX ## SYNTAX
``` ```
Get-XYRange [[-targetData] <Object>] Get-XYRange [[-TargetData] <Object>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -30,8 +30,8 @@ PS C:\> {{ Add example code here }}
## PARAMETERS ## PARAMETERS
### -targetData ### -TargetData
{{ Fill targetData Description }} {{ Fill TargetData Description }}
```yaml ```yaml
Type: Object Type: Object

View File

@@ -1,8 +1,8 @@
function Get-XYRange { function Get-XYRange {
[CmdletBinding()] [CmdletBinding()]
param($targetData) param($TargetData)
$record = $targetData | Select-Object -First 1 $record = $TargetData | Select-Object -First 1
$p=$record.psobject.Properties.name $p=$record.psobject.Properties.name
$infer = for ($idx = 0; $idx -lt $p.Count; $idx++) { $infer = for ($idx = 0; $idx -lt $p.Count; $idx++) {

View File

@@ -13,7 +13,7 @@ schema: 2.0.0
## SYNTAX ## SYNTAX
``` ```
Import-Html [[-url] <Object>] [[-index] <Object>] [[-Header] <Object>] [[-FirstDataRow] <Int32>] Import-Html [[-Url] <Object>] [[-Index] <Object>] [[-Header] <Object>] [[-FirstDataRow] <Int32>]
[-UseDefaultCredentials] [<CommonParameters>] [-UseDefaultCredentials] [<CommonParameters>]
``` ```
@@ -76,8 +76,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -index ### -Index
{{ Fill index Description }} {{ Fill Index Description }}
```yaml ```yaml
Type: Object Type: Object
@@ -91,8 +91,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -url ### -Url
{{ Fill url Description }} {{ Fill Url Description }}
```yaml ```yaml
Type: Object Type: Object

View File

@@ -2,8 +2,8 @@
function Import-Html { function Import-Html {
[CmdletBinding()] [CmdletBinding()]
param( param(
$url, $Url,
$index, $Index,
$Header, $Header,
[int]$FirstDataRow=0, [int]$FirstDataRow=0,
[Switch]$UseDefaultCredentials [Switch]$UseDefaultCredentials
@@ -14,7 +14,7 @@ function Import-Html {
Write-Verbose "Exporting to Excel file $($xlFile)" Write-Verbose "Exporting to Excel file $($xlFile)"
$data = Get-HtmlTable -url $url -tableIndex $index -Header $Header -FirstDataRow $FirstDataRow -UseDefaultCredentials: $UseDefaultCredentials $data = Get-HtmlTable -Url $Url -TableIndex $Index -Header $Header -FirstDataRow $FirstDataRow -UseDefaultCredentials: $UseDefaultCredentials
$data | Export-Excel $xlFile -Show -AutoSize $data | Export-Excel $xlFile -Show -AutoSize
} }

View File

@@ -13,7 +13,7 @@ schema: 2.0.0
## SYNTAX ## SYNTAX
``` ```
Invoke-Sum [[-data] <Object>] [[-dimension] <Object>] [[-measure] <Object>] Invoke-Sum [[-Data] <Object>] [[-Dimension] <Object>] [[-Measure] <Object>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -30,8 +30,8 @@ PS C:\> {{ Add example code here }}
## PARAMETERS ## PARAMETERS
### -data ### -Data
{{ Fill data Description }} {{ Fill Data Description }}
```yaml ```yaml
Type: Object Type: Object
@@ -45,8 +45,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -dimension ### -Dimension
{{ Fill dimension Description }} {{ Fill Dimension Description }}
```yaml ```yaml
Type: Object Type: Object
@@ -60,8 +60,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -measure ### -Measure
{{ Fill measure Description }} {{ Fill Measure Description }}
```yaml ```yaml
Type: Object Type: Object

View File

@@ -1,17 +1,17 @@
function Invoke-Sum { function Invoke-Sum {
[CmdletBinding()] [CmdletBinding()]
param( param(
$data, $Data,
$dimension, $Dimension,
$measure $Measure
) )
if(!$measure) {$measure = $dimension} if(!$Measure) {$Measure = $Dimension}
$h=@{} $h=@{}
foreach ($item in $data){ foreach ($item in $Data){
$key=$item.$dimension $key=$item.$Dimension
if(!$key) {$key="[missing]"} if(!$key) {$key="[missing]"}
@@ -19,7 +19,7 @@ function Invoke-Sum {
$h.$key=[ordered]@{} $h.$key=[ordered]@{}
} }
foreach($m in $measure) { foreach($m in $Measure) {
$value = $item.$m $value = $item.$m
if($value -is [string] -or $value -is [System.Enum]) { if($value -is [string] -or $value -is [System.Enum]) {
$value = 1 $value = 1

View File

@@ -55,7 +55,7 @@
) )
#region get target worksheet, select it and move it to the end. #region get target worksheet, select it and move it to the end.
if ($Path -and -not $ExcelPackage) {$ExcelPackage = Open-ExcelPackage -path $Path } if ($Path -and -not $ExcelPackage) {$ExcelPackage = Open-ExcelPackage -path $Path }
$destinationSheet = Add-Worksheet -ExcelPackage $ExcelPackage -WorkSheetname $WorksheetName -ClearSheet:$Clearsheet $destinationSheet = Add-Worksheet -ExcelPackage $ExcelPackage -WorksheetName $WorksheetName -ClearSheet:$Clearsheet
foreach ($w in $ExcelPackage.Workbook.Worksheets) {$w.view.TabSelected = $false} foreach ($w in $ExcelPackage.Workbook.Worksheets) {$w.view.TabSelected = $false}
$destinationSheet.View.TabSelected = $true $destinationSheet.View.TabSelected = $true
$ExcelPackage.Workbook.Worksheets.MoveToEnd($WorksheetName) $ExcelPackage.Workbook.Worksheets.MoveToEnd($WorksheetName)
@@ -123,7 +123,7 @@
'Title', 'TitleFillPattern', 'TitleBackgroundColor', 'TitleBold', 'TitleSize' | ForEach-Object {$null = $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
$params.ExcelPackage = $ExcelPackage $params.ExcelPackage = $ExcelPackage
Export-Excel @Params Export-Excel @Params
} }

View File

@@ -75,7 +75,7 @@
$orderByProperties = $merged[0].psobject.properties.where({$_.name -match "row$"}).name $orderByProperties = $merged[0].psobject.properties.where({$_.name -match "row$"}).name
Write-Progress -Activity "Merging sheets" -CurrentOperation "creating output sheet '$OutputSheetName' in $OutputFile" Write-Progress -Activity "Merging sheets" -CurrentOperation "creating output sheet '$OutputSheetName' in $OutputFile"
$excel = $merged | Sort-Object -Property $orderByProperties | $excel = $merged | Sort-Object -Property $orderByProperties |
Export-Excel -Path $OutputFile -Worksheetname $OutputSheetName -ClearSheet -BoldTopRow -AutoFilter -PassThru Export-Excel -Path $OutputFile -WorksheetName $OutputSheetName -ClearSheet -BoldTopRow -AutoFilter -PassThru
$sheet = $excel.Workbook.Worksheets[$OutputSheetName] $sheet = $excel.Workbook.Worksheets[$OutputSheetName]
#We will put in a conditional format for "if all the others are not flagged as 'same'" to mark rows where something is added, removed or changed #We will put in a conditional format for "if all the others are not flagged as 'same'" to mark rows where something is added, removed or changed

View File

@@ -233,7 +233,7 @@
elseif ($PSCmdlet.ShouldProcess($OutputFile,"Write Output to Excel file")) { elseif ($PSCmdlet.ShouldProcess($OutputFile,"Write Output to Excel file")) {
$expandedDiff = $expandedDiff | Sort-Object -Property "_row", "$DiffPrefix Row" $expandedDiff = $expandedDiff | Sort-Object -Property "_row", "$DiffPrefix Row"
$xl = $expandedDiff | Select-Object -Property $OutputProps | Update-FirstObjectProperties | $xl = $expandedDiff | Select-Object -Property $OutputProps | Update-FirstObjectProperties |
Export-Excel -Path $OutputFile -Worksheetname $OutputSheetName -FreezeTopRow -BoldTopRow -AutoSize -AutoFilter -PassThru Export-Excel -Path $OutputFile -WorksheetName $OutputSheetName -FreezeTopRow -BoldTopRow -AutoSize -AutoFilter -PassThru
$ws = $xl.Workbook.Worksheets[$OutputSheetName] $ws = $xl.Workbook.Worksheets[$OutputSheetName]
for ($i = 0; $i -lt $expandedDiff.Count; $i++ ) { for ($i = 0; $i -lt $expandedDiff.Count; $i++ ) {
if ( $expandedDiff[$i].side -ne "==" ) { if ( $expandedDiff[$i].side -ne "==" ) {

View File

@@ -5,7 +5,7 @@ function New-PivotTableDefinition {
[Parameter(Mandatory)] [Parameter(Mandatory)]
[Alias("PivtoTableName")]#Previous typo - use alias to avoid breaking scripts [Alias("PivtoTableName")]#Previous typo - use alias to avoid breaking scripts
$PivotTableName, $PivotTableName,
$SourceWorkSheet, $SourceWorksheet,
$SourceRange, $SourceRange,
$PivotRows, $PivotRows,
[hashtable]$PivotData, [hashtable]$PivotData,

View File

@@ -9,7 +9,7 @@
[Parameter(ParameterSetName="ExistingSession", Mandatory=$true)] [Parameter(ParameterSetName="ExistingSession", Mandatory=$true)]
$Session, $Session,
[Parameter(ParameterSetName="SQLConnection", Mandatory=$true)] [Parameter(ParameterSetName="SQLConnection", Mandatory=$true)]
[switch]$MsSQLserver, [switch]$MsSqlServer,
[Parameter(ParameterSetName="SQLConnection")] [Parameter(ParameterSetName="SQLConnection")]
[String]$DataBase, [String]$DataBase,
[Parameter(ParameterSetName="SQLConnection", Mandatory=$true)] [Parameter(ParameterSetName="SQLConnection", Mandatory=$true)]
@@ -46,10 +46,10 @@
$null = $PSBoundParameters.Remove('AutoFilter') $null = $PSBoundParameters.Remove('AutoFilter')
} }
#endregion #endregion
#region if we were either given a session object or a connection string (& optionally -MSSQLServer) make sure we can connect #region if we were either given a session object or a connection string (& optionally -MsSqlServer) make sure we can connect
try { try {
#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
if ($MsSQLserver -and $Connection) { if ($MsSqlServer -and $Connection) {
if ($Connection -notmatch '=') {$Connection = "server=$Connection;trusted_connection=true;timeout=60"} if ($Connection -notmatch '=') {$Connection = "server=$Connection;trusted_connection=true;timeout=60"}
$Session = New-Object -TypeName System.Data.SqlClient.SqlConnection -ArgumentList $Connection $Session = New-Object -TypeName System.Data.SqlClient.SqlConnection -ArgumentList $Connection
if ($Session.State -ne 'Open') {$Session.Open()} if ($Session.State -ne 'Open') {$Session.Open()}
@@ -90,7 +90,7 @@
#endregion #endregion
#region send the table to Excel #region send the table to Excel
#remove parameters which relate to querying SQL, leaving the ones used by Export-Excel #remove parameters which relate to querying SQL, leaving the ones used by Export-Excel
'Connection' , 'Database' , 'Session' , 'MsSQLserver' , 'SQL' , 'DataTable' , 'QueryTimeout' , 'Force' | 'Connection' , 'Database' , 'Session' , 'MsSqlServer' , 'SQL' , 'DataTable' , 'QueryTimeout' , 'Force' |
ForEach-Object {$null = $PSBoundParameters.Remove($_) } ForEach-Object {$null = $PSBoundParameters.Remove($_) }
#if force was specified export even if there are no rows. If there are no columns, the query failed and export "null" if forced #if force was specified export even if there are no rows. If there are no columns, the query failed and export "null" if forced
if ($DataTable.Rows.Count) { if ($DataTable.Rows.Count) {

View File

@@ -13,7 +13,7 @@ schema: 2.0.0
## SYNTAX ## SYNTAX
``` ```
Set-CellStyle [[-WorkSheet] <Object>] [[-Row] <Object>] [[-LastColumn] <Object>] [[-Pattern] <ExcelFillStyle>] Set-CellStyle [[-Worksheet] <Object>] [[-Row] <Object>] [[-LastColumn] <Object>] [[-Pattern] <ExcelFillStyle>]
[[-Color] <Object>] [[-Color] <Object>]
``` ```
@@ -92,8 +92,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -WorkSheet ### -Worksheet
{{ Fill WorkSheet Description }} {{ Fill Worksheet Description }}
```yaml ```yaml
Type: Object Type: Object

View File

@@ -5,7 +5,7 @@ online version:
schema: 2.0.0 schema: 2.0.0
--- ---
# Set-WorkSheetProtection # Set-WorksheetProtection
## SYNOPSIS ## SYNOPSIS
{{ Fill in the Synopsis }} {{ Fill in the Synopsis }}
@@ -13,7 +13,7 @@ schema: 2.0.0
## SYNTAX ## SYNTAX
``` ```
Set-WorkSheetProtection [-WorkSheet] <ExcelWorksheet> [-IsProtected] [-AllowAll] [-BlockSelectLockedCells] Set-WorksheetProtection [-Worksheet] <ExcelWorksheet> [-IsProtected] [-AllowAll] [-BlockSelectLockedCells]
[-BlockSelectUnlockedCells] [-AllowFormatCells] [-AllowFormatColumns] [-AllowFormatRows] [-AllowInsertColumns] [-BlockSelectUnlockedCells] [-AllowFormatCells] [-AllowFormatColumns] [-AllowFormatRows] [-AllowInsertColumns]
[-AllowInsertRows] [-AllowInsertHyperlinks] [-AllowDeleteColumns] [-AllowDeleteRows] [-AllowSort] [-AllowInsertRows] [-AllowInsertHyperlinks] [-AllowDeleteColumns] [-AllowDeleteRows] [-AllowSort]
[-AllowAutoFilter] [-AllowPivotTables] [-BlockEditObject] [-BlockEditScenarios] [[-LockAddress] <String>] [-AllowAutoFilter] [-AllowPivotTables] [-BlockEditObject] [-BlockEditScenarios] [[-LockAddress] <String>]
@@ -319,8 +319,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -WorkSheet ### -Worksheet
{{ Fill WorkSheet Description }} {{ Fill Worksheet Description }}
```yaml ```yaml
Type: ExcelWorksheet Type: ExcelWorksheet