mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 21:33:16 +00:00
Name of pivot table comes from caller
This commit is contained in:
@@ -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
|
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user