mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added ValueFromPipeline to the data parameter
This commit is contained in:
54
Charting.ps1
54
Charting.ps1
@@ -1,11 +1,11 @@
|
||||
function DoChart {
|
||||
param(
|
||||
$targetData,
|
||||
$title,
|
||||
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType,
|
||||
[Switch]$NoLegend,
|
||||
[Switch]$ShowCategory,
|
||||
[Switch]$ShowPercent
|
||||
$title,
|
||||
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType,
|
||||
[Switch]$NoLegend,
|
||||
[Switch]$ShowCategory,
|
||||
[Switch]$ShowPercent
|
||||
)
|
||||
|
||||
if($targetData[0] -is [System.ValueType]) {
|
||||
@@ -25,11 +25,11 @@ function DoChart {
|
||||
|
||||
$xlFile = (New-TemporaryFile).fullname -replace "tmp","xlsx"
|
||||
$targetData | Export-Excel $xlFile -ExcelChartDefinition $chart -Show -AutoSize
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function BarChart {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$true)]
|
||||
$targetData,
|
||||
$title,
|
||||
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="BarStacked",
|
||||
@@ -38,13 +38,18 @@ function BarChart {
|
||||
[Switch]$ShowPercent
|
||||
)
|
||||
|
||||
DoChart $targetData $title -ChartType $ChartType `
|
||||
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
|
||||
Begin { $data = @() }
|
||||
Process { $data += $targetData}
|
||||
|
||||
}
|
||||
End {
|
||||
DoChart $data $title -ChartType $ChartType `
|
||||
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
|
||||
}
|
||||
}
|
||||
|
||||
function PieChart {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$true)]
|
||||
$targetData,
|
||||
$title,
|
||||
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="PieExploded3D",
|
||||
@@ -53,12 +58,18 @@ function PieChart {
|
||||
[Switch]$ShowPercent
|
||||
)
|
||||
|
||||
DoChart $targetData $title -ChartType $ChartType `
|
||||
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
|
||||
Begin { $data = @() }
|
||||
Process { $data += $targetData}
|
||||
|
||||
End {
|
||||
DoChart $data $title -ChartType $ChartType `
|
||||
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
|
||||
}
|
||||
}
|
||||
|
||||
function LineChart {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$true)]
|
||||
$targetData,
|
||||
$title,
|
||||
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="Line",
|
||||
@@ -67,12 +78,18 @@ function LineChart {
|
||||
[Switch]$ShowPercent
|
||||
)
|
||||
|
||||
DoChart $targetData $title -ChartType $ChartType `
|
||||
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
|
||||
Begin { $data = @() }
|
||||
Process { $data += $targetData}
|
||||
|
||||
End {
|
||||
DoChart $data $title -ChartType $ChartType `
|
||||
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
|
||||
}
|
||||
}
|
||||
|
||||
function ColumnChart {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$true)]
|
||||
$targetData,
|
||||
$title,
|
||||
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="ColumnStacked",
|
||||
@@ -81,6 +98,11 @@ function ColumnChart {
|
||||
[Switch]$ShowPercent
|
||||
)
|
||||
|
||||
DoChart $targetData $title -ChartType $ChartType `
|
||||
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
|
||||
Begin { $data = @() }
|
||||
Process { $data += $targetData}
|
||||
|
||||
End {
|
||||
DoChart $data $title -ChartType $ChartType `
|
||||
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,13 @@ Known Issues
|
||||
What's new
|
||||
-
|
||||
|
||||
#### 12/26/2015
|
||||
|
||||
* Added `NoLegend`, `Show-Category`, `ShowPercent` for all charts including Pivot Charts
|
||||
* Updated PieChart, BarChart, ColumnChart and Line chart to work with the pipeline and added `NoLegend`, `Show-Category`, `ShowPercent`
|
||||
|
||||
#### 12/17/2015
|
||||
|
||||
These new features open the door for really sophisticated work sheet creation.
|
||||
|
||||
Stay tuned for a [blog post](http://www.dougfinke.com/blog/) and examples.
|
||||
|
||||
Reference in New Issue
Block a user