mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
updated
This commit is contained in:
@@ -1,19 +1,26 @@
|
|||||||
$file="C:\Temp\test.xlsx"
|
Import-Module ..\ImportExcel.psd1 -Force
|
||||||
|
|
||||||
rm $file -ErrorAction Ignore -Force
|
$file = "C:\Temp\test.xlsx"
|
||||||
|
|
||||||
|
Remove-Item $file -ErrorAction Ignore -Force
|
||||||
|
|
||||||
$ptd = @{}
|
$base = @{
|
||||||
$base=@{
|
SourceWorkSheet = 'gsv'
|
||||||
SourceWorkSheet='gsv'
|
PivotData = @{'Status' = 'count'}
|
||||||
PivotData= @{'Status'='count'}
|
IncludePivotChart = $true
|
||||||
IncludePivotChart=$true
|
# ChartType = 'BarClustered3D'
|
||||||
ChartType='BarClustered3D'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ptd.gpt1 = $base + @{ PivotRows = "ServiceType" }
|
$ptd = [ordered]@{}
|
||||||
$ptd.gpt2 = $base + @{ PivotRows = "Status" }
|
|
||||||
$ptd.gpt3 = $base + @{ PivotRows = "StartType" }
|
|
||||||
$ptd.gpt4 = $base + @{ PivotRows = "CanStop" }
|
|
||||||
|
|
||||||
gsv | Export-Excel -path $file -WorkSheetname gsv -Show -PivotTableDefinition $ptd
|
# $ptd.gpt1 = $base + @{ PivotRows = "ServiceType" }
|
||||||
|
# $ptd.gpt2 = $base + @{ PivotRows = "Status" }
|
||||||
|
# $ptd.gpt3 = $base + @{ PivotRows = "StartType" }
|
||||||
|
# $ptd.gpt4 = $base + @{ PivotRows = "CanStop" }
|
||||||
|
|
||||||
|
$ptd += New-PivotTableDefinition @base servicetype -PivotRows servicetype -ChartType Area3D
|
||||||
|
$ptd += New-PivotTableDefinition @base status -PivotRows status -ChartType PieExploded3D
|
||||||
|
$ptd += New-PivotTableDefinition @base starttype -PivotRows starttype -ChartType BarClustered3D
|
||||||
|
$ptd += New-PivotTableDefinition @base canstop -PivotRows canstop -ChartType ConeColStacked
|
||||||
|
|
||||||
|
Get-Service | Export-Excel -path $file -WorkSheetname gsv -Show -PivotTableDefinition $ptd
|
||||||
@@ -554,7 +554,7 @@ Function Export-Excel {
|
|||||||
else {
|
else {
|
||||||
$workSheet = Find-WorkSheet $item.Value.SourceWorkSheet
|
$workSheet = Find-WorkSheet $item.Value.SourceWorkSheet
|
||||||
|
|
||||||
if($workSheet) {
|
if ($workSheet) {
|
||||||
$targetStartAddress = $workSheet.Dimension.Start.Address
|
$targetStartAddress = $workSheet.Dimension.Start.Address
|
||||||
$targetDataRange = "{0}:{1}" -f $targetStartAddress, $workSheet.Dimension.End.Address
|
$targetDataRange = "{0}:{1}" -f $targetStartAddress, $workSheet.Dimension.End.Address
|
||||||
|
|
||||||
@@ -804,4 +804,22 @@ Function Export-Excel {
|
|||||||
throw "Failed exporting worksheet '$WorkSheetname' to '$Path': $_"
|
throw "Failed exporting worksheet '$WorkSheetname' to '$Path': $_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function New-PivotTableDefinition {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
$PivtoTableName,
|
||||||
|
$SourceWorkSheet,
|
||||||
|
$PivotRows,
|
||||||
|
[hashtable]$PivotData,
|
||||||
|
$PivotColumns,
|
||||||
|
[Switch]$IncludePivotChart,
|
||||||
|
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType = 'Pie'
|
||||||
|
)
|
||||||
|
|
||||||
|
$parameters = @{} + $PSBoundParameters
|
||||||
|
$parameters.Remove('PivtoTableName')
|
||||||
|
|
||||||
|
@{$PivtoTableName=$parameters}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user