Name of pivot table comes from caller

This commit is contained in:
dfinke
2017-10-12 12:06:16 -04:00
parent 57c02a466d
commit 48607e403e
2 changed files with 7 additions and 14 deletions

View File

@@ -2,20 +2,18 @@
ipmo .\ImportExcel.psd1 -Force ipmo .\ImportExcel.psd1 -Force
$pt=[ordered]@{} $pt=[ordered]@{}
$pt.PT1=@{ $pt.ServiceInfo=@{
SourceWorkSheet='Services'
SourceWorkSheet='Sheet1'
PivotRows = "Status" PivotRows = "Status"
PivotData= @{'Status'='count'} PivotData= @{'Status'='count'}
IncludePivotChart=$true IncludePivotChart=$true
ChartType='BarClustered3D' ChartType='BarClustered3D'
} }
$pt.PT2=@{ $pt.ProcessInfo=@{
SourceWorkSheet='Sheet2' SourceWorkSheet='Processes'
PivotRows = "Company" PivotRows = "Company"
PivotData= @{'Company'='count'} PivotData= @{'Company'='count'}
IncludePivotChart=$true IncludePivotChart=$true
@@ -28,10 +26,5 @@ $ps=Get-Process | Select-Object Name,Company, Handles
$file = "c:\temp\testPT.xlsx" $file = "c:\temp\testPT.xlsx"
rm $file -ErrorAction Ignore rm $file -ErrorAction Ignore
$gsv| Export-Excel -Path $file -AutoSize $gsv| Export-Excel -Path $file -AutoSize -WorkSheetname Services
$ps | Export-Excel -Path $file -AutoSize -WorkSheetname Sheet2 -PivotTableDefinition $pt -Show $ps | Export-Excel -Path $file -AutoSize -WorkSheetname Processes -PivotTableDefinition $pt -Show
return
Get-Service |
select status, Name, displayName, starttype |
Export-Excel -Path $file -Show -PivotTable $pt -AutoSize

View File

@@ -544,7 +544,7 @@ Function Export-Excel {
if ($PivotTableDefinition) { if ($PivotTableDefinition) {
foreach ($item in $PivotTableDefinition.GetEnumerator()) { foreach ($item in $PivotTableDefinition.GetEnumerator()) {
$targetName = $item.Key $targetName = $item.Key
$pivotTableName = $targetName + 'PivotTable' $pivotTableName = $targetName #+ 'PivotTable'
$wsPivot = $pkg | Add-WorkSheet -WorkSheetname $pivotTableName -NoClobber:$NoClobber $wsPivot = $pkg | Add-WorkSheet -WorkSheetname $pivotTableName -NoClobber:$NoClobber
$pivotTableDataName = $targetName + 'PivotTableData' $pivotTableDataName = $targetName + 'PivotTableData'