mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-14 23:33:18 +00:00
Add TotalSettings parameter to Export-Excel
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
[Alias('Table')]
|
[Alias('Table')]
|
||||||
$TableName,
|
$TableName,
|
||||||
[OfficeOpenXml.Table.TableStyles]$TableStyle = [OfficeOpenXml.Table.TableStyles]::Medium6,
|
[OfficeOpenXml.Table.TableStyles]$TableStyle = [OfficeOpenXml.Table.TableStyles]::Medium6,
|
||||||
|
[HashTable]$TotalSettings,
|
||||||
[Switch]$BarChart,
|
[Switch]$BarChart,
|
||||||
[Switch]$PieChart,
|
[Switch]$PieChart,
|
||||||
[Switch]$LineChart ,
|
[Switch]$LineChart ,
|
||||||
@@ -211,9 +212,14 @@
|
|||||||
$row ++
|
$row ++
|
||||||
$null = $ws.Cells[$row, $StartColumn].LoadFromDataTable($InputObject, $false )
|
$null = $ws.Cells[$row, $StartColumn].LoadFromDataTable($InputObject, $false )
|
||||||
if ($TableName -or $PSBoundParameters.ContainsKey('TableStyle')) {
|
if ($TableName -or $PSBoundParameters.ContainsKey('TableStyle')) {
|
||||||
|
if ($PSBoundParameters.ContainsKey('TotalSettings')) {
|
||||||
|
Add-ExcelTable -Range $ws.Cells[$ws.Dimension] -TableName $TableName -TableStyle $TableStyle -TotalSettings $TotalSettings
|
||||||
|
}
|
||||||
|
Else {
|
||||||
Add-ExcelTable -Range $ws.Cells[$ws.Dimension] -TableName $TableName -TableStyle $TableStyle
|
Add-ExcelTable -Range $ws.Cells[$ws.Dimension] -TableName $TableName -TableStyle $TableStyle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
#Change TableName if $TableName is non-empty; don't leave caller with a renamed table!
|
#Change TableName if $TableName is non-empty; don't leave caller with a renamed table!
|
||||||
$orginalTableName = $InputObject.TableName
|
$orginalTableName = $InputObject.TableName
|
||||||
@@ -424,9 +430,14 @@
|
|||||||
if ($null -ne $TableName -or $PSBoundParameters.ContainsKey('TableStyle')) {
|
if ($null -ne $TableName -or $PSBoundParameters.ContainsKey('TableStyle')) {
|
||||||
#Already inserted Excel table if input was a DataTable
|
#Already inserted Excel table if input was a DataTable
|
||||||
if ($InputObject -isnot [System.Data.DataTable]) {
|
if ($InputObject -isnot [System.Data.DataTable]) {
|
||||||
|
if ($PSBoundParameters.ContainsKey('TotalSettings')) {
|
||||||
|
Add-ExcelTable -Range $ws.Cells[$dataRange] -TableName $TableName -TableStyle $TableStyle -TotalSettings $TotalSettings
|
||||||
|
}
|
||||||
|
else {
|
||||||
Add-ExcelTable -Range $ws.Cells[$dataRange] -TableName $TableName -TableStyle $TableStyle
|
Add-ExcelTable -Range $ws.Cells[$dataRange] -TableName $TableName -TableStyle $TableStyle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
elseif ($AutoFilter) {
|
elseif ($AutoFilter) {
|
||||||
try {
|
try {
|
||||||
$ws.Cells[$dataRange].AutoFilter = $true
|
$ws.Cells[$dataRange].AutoFilter = $true
|
||||||
|
|||||||
Reference in New Issue
Block a user