mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-15 07:43:23 +00:00
Changes to match latest style rules (trailing spaces & position of null)
This commit is contained in:
114
Export-Excel.ps1
114
Export-Excel.ps1
@@ -37,7 +37,7 @@
|
|||||||
.PARAMETER IncludePivotTable
|
.PARAMETER IncludePivotTable
|
||||||
Adds a Pivot table using the data in the worksheet.
|
Adds a Pivot table using the data in the worksheet.
|
||||||
.PARAMETER PivotTableName
|
.PARAMETER PivotTableName
|
||||||
If a Pivot table is created from command line parameters, specificies the name of the new sheet holding the pivot. If Omitted this will be "WorksheetName-PivotTable"
|
If a Pivot table is created from command line parameters, specificies the name of the new sheet holding the pivot. If Omitted this will be "WorksheetName-PivotTable"
|
||||||
.PARAMETER PivotRows
|
.PARAMETER PivotRows
|
||||||
Name(s) columns from the spreadhseet which will provide the Row name(s) in a pivot table created from command line parameters.
|
Name(s) columns from the spreadhseet which will provide the Row name(s) in a pivot table created from command line parameters.
|
||||||
.PARAMETER PivotColumns
|
.PARAMETER PivotColumns
|
||||||
@@ -50,19 +50,19 @@
|
|||||||
In a pivot table created from command line parameters, prevents the addition of totals to rows and columns.
|
In a pivot table created from command line parameters, prevents the addition of totals to rows and columns.
|
||||||
.PARAMETER PivotTableDefinition
|
.PARAMETER PivotTableDefinition
|
||||||
Instead of describing a single pivot table with mutliple commandline paramters; you can use a HashTable in the form PivotTableName = Definition;
|
Instead of describing a single pivot table with mutliple commandline paramters; you can use a HashTable in the form PivotTableName = Definition;
|
||||||
Definition is itself a hashtable with Sheet PivotTows, PivotColumns, PivotData, IncludePivotChart and ChartType values.
|
Definition is itself a hashtable with Sheet PivotTows, PivotColumns, PivotData, IncludePivotChart and ChartType values.
|
||||||
.PARAMETER IncludePivotChart
|
.PARAMETER IncludePivotChart
|
||||||
Include a chart with the Pivot table - implies -IncludePivotTable.
|
Include a chart with the Pivot table - implies -IncludePivotTable.
|
||||||
.PARAMETER ChartType
|
.PARAMETER ChartType
|
||||||
The type for Pivot chart (one of Excel's defined chart types)
|
The type for Pivot chart (one of Excel's defined chart types)
|
||||||
.PARAMETER NoLegend
|
.PARAMETER NoLegend
|
||||||
Exclude the legend from the pivot chart.
|
Exclude the legend from the pivot chart.
|
||||||
.PARAMETER ShowCategory
|
.PARAMETER ShowCategory
|
||||||
Add category labels to the pivot chart.
|
Add category labels to the pivot chart.
|
||||||
.PARAMETER ShowPercent
|
.PARAMETER ShowPercent
|
||||||
Add Percentage labels to the pivot chart.
|
Add Percentage labels to the pivot chart.
|
||||||
.PARAMETER ConditionalFormat
|
.PARAMETER ConditionalFormat
|
||||||
One or more conditional formatting rules defined with New-ConditionalFormattingIconSet.
|
One or more conditional formatting rules defined with New-ConditionalFormattingIconSet.
|
||||||
.PARAMETER ConditionalText
|
.PARAMETER ConditionalText
|
||||||
Applies a 'Conditional formatting rule' in Excel on all the cells. When specific conditions are met a rule is triggered.
|
Applies a 'Conditional formatting rule' in Excel on all the cells. When specific conditions are met a rule is triggered.
|
||||||
.PARAMETER NoNumberConversion
|
.PARAMETER NoNumberConversion
|
||||||
@@ -82,9 +82,9 @@
|
|||||||
.PARAMETER ColumnChart
|
.PARAMETER ColumnChart
|
||||||
Creates a "quick" column chart using the first text column as labels and the first numeric column as values
|
Creates a "quick" column chart using the first text column as labels and the first numeric column as values
|
||||||
.PARAMETER LineChart
|
.PARAMETER LineChart
|
||||||
Creates a "quick" line chart using the first text column as labels and the first numeric column as values
|
Creates a "quick" line chart using the first text column as labels and the first numeric column as values
|
||||||
.PARAMETER PieChart
|
.PARAMETER PieChart
|
||||||
Creates a "quick" pie chart using the first text column as labels and the first numeric column as values
|
Creates a "quick" pie chart using the first text column as labels and the first numeric column as values
|
||||||
.PARAMETER ExcelChartDefinition
|
.PARAMETER ExcelChartDefinition
|
||||||
A hash table containing ChartType, Title, NoLegend, ShowCategory, ShowPercent, Yrange, Xrange and SeriesHeader for one or more [non-pivot] charts.
|
A hash table containing ChartType, Title, NoLegend, ShowCategory, ShowPercent, Yrange, Xrange and SeriesHeader for one or more [non-pivot] charts.
|
||||||
.PARAMETER HideSheet
|
.PARAMETER HideSheet
|
||||||
@@ -152,11 +152,11 @@
|
|||||||
'[Blue]$#,##0.00;[Red]-$#,##0.00'
|
'[Blue]$#,##0.00;[Red]-$#,##0.00'
|
||||||
|
|
||||||
.PARAMETER ReZip
|
.PARAMETER ReZip
|
||||||
If specified, Export-Excel will expand the contents of the .XLSX file (which is multiple files in a zip archive) and rebuilt it.
|
If specified, Export-Excel will expand the contents of the .XLSX file (which is multiple files in a zip archive) and rebuilt it.
|
||||||
.PARAMETER Show
|
.PARAMETER Show
|
||||||
Opens the Excel file immediately after creation. Convenient for viewing the results instantly without having to search for the file first.
|
Opens the Excel file immediately after creation. Convenient for viewing the results instantly without having to search for the file first.
|
||||||
.PARAMETER ReturnRange
|
.PARAMETER ReturnRange
|
||||||
If specified, Export-Excel returns the range of added cells in the format "A1:Z100"
|
If specified, Export-Excel returns the range of added cells in the format "A1:Z100"
|
||||||
.PARAMETER PassThru
|
.PARAMETER PassThru
|
||||||
If specified, Export-Excel returns an object representing the Excel package without saving the package first. To save it you need to call the save or Saveas method or send it back to Export-Excel.
|
If specified, Export-Excel returns an object representing the Excel package without saving the package first. To save it you need to call the save or Saveas method or send it back to Export-Excel.
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@
|
|||||||
[Switch]$Barchart,
|
[Switch]$Barchart,
|
||||||
[Switch]$PieChart,
|
[Switch]$PieChart,
|
||||||
[Switch]$LineChart ,
|
[Switch]$LineChart ,
|
||||||
[Switch]$ColumnChart ,
|
[Switch]$ColumnChart ,
|
||||||
[Object[]]$ExcelChartDefinition,
|
[Object[]]$ExcelChartDefinition,
|
||||||
[String[]]$HideSheet,
|
[String[]]$HideSheet,
|
||||||
[Switch]$MoveToStart,
|
[Switch]$MoveToStart,
|
||||||
@@ -616,7 +616,7 @@
|
|||||||
|
|
||||||
if ($isDataTypeValueType) {
|
if ($isDataTypeValueType) {
|
||||||
$ColumnIndex = $StartColumn
|
$ColumnIndex = $StartColumn
|
||||||
$Row += 1
|
$Row += 1
|
||||||
Add-CellValue -TargetCell $ws.Cells[$Row, $ColumnIndex] -CellValue $TargetData
|
Add-CellValue -TargetCell $ws.Cells[$Row, $ColumnIndex] -CellValue $TargetData
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -654,7 +654,7 @@
|
|||||||
$ColumnIndex += 1
|
$ColumnIndex += 1
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
$ColumnIndex -= 1 # column index will be the last column whether isDataTypeValueType was true or false
|
$ColumnIndex -= 1 # column index will be the last column whether isDataTypeValueType was true or false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
@@ -670,11 +670,11 @@
|
|||||||
$endAddress = $ws.Dimension.End.Address
|
$endAddress = $ws.Dimension.End.Address
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$LastRow = $Row
|
$LastRow = $Row
|
||||||
$LastCol = $ColumnIndex
|
$LastCol = $ColumnIndex
|
||||||
$endAddress = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$LastRow]C[$LastCol]", 0, 0)
|
$endAddress = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$LastRow]C[$LastCol]", 0, 0)
|
||||||
}
|
}
|
||||||
$startAddress = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$StartRow]C[$StartColumn]", 0, 0)
|
$startAddress = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$StartRow]C[$StartColumn]", 0, 0)
|
||||||
$dataRange = "{0}:{1}" -f $startAddress, $endAddress
|
$dataRange = "{0}:{1}" -f $startAddress, $endAddress
|
||||||
|
|
||||||
Write-Debug "Data Range '$dataRange'"
|
Write-Debug "Data Range '$dataRange'"
|
||||||
@@ -711,7 +711,7 @@
|
|||||||
}
|
}
|
||||||
Catch {Write-Warning -Message "Failed adding named ranges to worksheet '$WorkSheetname': $_" }
|
Catch {Write-Warning -Message "Failed adding named ranges to worksheet '$WorkSheetname': $_" }
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($RangeName) {
|
if ($RangeName) {
|
||||||
try {
|
try {
|
||||||
if ($RangeName -match "\W") {
|
if ($RangeName -match "\W") {
|
||||||
@@ -817,7 +817,7 @@
|
|||||||
catch {Write-Warning -Message "Failed adding Freezing the panes in worksheet '$WorkSheetname': $_"}
|
catch {Write-Warning -Message "Failed adding Freezing the panes in worksheet '$WorkSheetname': $_"}
|
||||||
|
|
||||||
if ($BoldTopRow) { #it sets bold as far as there are populated cells: for whole row could do $ws.row($x).style.font.bold = $true
|
if ($BoldTopRow) { #it sets bold as far as there are populated cells: for whole row could do $ws.row($x).style.font.bold = $true
|
||||||
try {
|
try {
|
||||||
if ($Title) {
|
if ($Title) {
|
||||||
$range = $ws.Dimension.Address -replace '\d+', ($StartRow + 1)
|
$range = $ws.Dimension.Address -replace '\d+', ($StartRow + 1)
|
||||||
}
|
}
|
||||||
@@ -847,33 +847,33 @@
|
|||||||
|
|
||||||
foreach ($chartDef in $ExcelChartDefinition) {
|
foreach ($chartDef in $ExcelChartDefinition) {
|
||||||
$params = @{}
|
$params = @{}
|
||||||
$chartDef.PSObject.Properties | ForEach-Object {if ($_.value -ne $null) {$params[$_.name] = $_.value}}
|
$chartDef.PSObject.Properties | ForEach-Object {if ( $null -ne $_.value) {$params[$_.name] = $_.value}}
|
||||||
Add-ExcelChart -Worksheet $ws @params
|
Add-ExcelChart -Worksheet $ws @params
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Barchart -or $PieChart -or $LineChart -or $ColumnChart) {
|
if ($Barchart -or $PieChart -or $LineChart -or $ColumnChart) {
|
||||||
if ($NoHeader) {$FirstDataRow = $startRow}
|
if ($NoHeader) {$FirstDataRow = $startRow}
|
||||||
else {$FirstDataRow = $startRow + 1 }
|
else {$FirstDataRow = $startRow + 1 }
|
||||||
$range = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$FirstDataRow]C[$startColumn]:R[$FirstDataRow]C[$lastCol]",0,0)
|
$range = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$FirstDataRow]C[$startColumn]:R[$FirstDataRow]C[$lastCol]",0,0)
|
||||||
$xCol = $ws.cells[$range] | Where-Object {$_.value -is [string] } | ForEach-Object {$_.start.column} | Sort-Object | Select-Object -first 1
|
$xCol = $ws.cells[$range] | Where-Object {$_.value -is [string] } | ForEach-Object {$_.start.column} | Sort-Object | Select-Object -first 1
|
||||||
$yCol = $ws.cells[$range] | Where-Object {$_.value -is [valueType] } | ForEach-Object {$_.start.column} | Sort-Object | Select-Object -first 1
|
$yCol = $ws.cells[$range] | Where-Object {$_.value -is [valueType] } | ForEach-Object {$_.start.column} | Sort-Object | Select-Object -first 1
|
||||||
$params = @{
|
$params = @{
|
||||||
xrange = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$FirstDataRow]C[$xcol]:R[$($lastrow)]C[$xcol]",0,0) ;
|
xrange = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$FirstDataRow]C[$xcol]:R[$($lastrow)]C[$xcol]",0,0) ;
|
||||||
yrange = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$FirstDataRow]C[$ycol]:R[$($lastrow)]C[$ycol]",0,0) ;
|
yrange = [OfficeOpenXml.ExcelAddress]::TranslateFromR1C1("R[$FirstDataRow]C[$ycol]:R[$($lastrow)]C[$ycol]",0,0) ;
|
||||||
title = "";
|
title = "";
|
||||||
Column = ($lastCol +1) ;
|
Column = ($lastCol +1) ;
|
||||||
Width = 1200
|
Width = 1200
|
||||||
}
|
}
|
||||||
if ($NoHeader) {$params["NoHeader"] = $true}
|
if ($NoHeader) {$params["NoHeader"] = $true}
|
||||||
else {$Params["SeriesHeader"] = $ws.Cells[$startRow, $YCol].Value}
|
else {$Params["SeriesHeader"] = $ws.Cells[$startRow, $YCol].Value}
|
||||||
if ($ColumnChart) {$Params["chartType"] = "ColumnStacked" }
|
if ($ColumnChart) {$Params["chartType"] = "ColumnStacked" }
|
||||||
elseif ($Barchart) {$Params["chartType"] = "BarStacked" }
|
elseif ($Barchart) {$Params["chartType"] = "BarStacked" }
|
||||||
elseif ($PieChart) {$Params["chartType"] = "PieExploded3D" }
|
elseif ($PieChart) {$Params["chartType"] = "PieExploded3D" }
|
||||||
elseif ($LineChart) {$Params["chartType"] = "Line" }
|
elseif ($LineChart) {$Params["chartType"] = "Line" }
|
||||||
|
|
||||||
Add-ExcelChart -Worksheet $ws @params
|
|
||||||
|
|
||||||
}
|
Add-ExcelChart -Worksheet $ws @params
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($ct in $ConditionalText) {
|
foreach ($ct in $ConditionalText) {
|
||||||
try {
|
try {
|
||||||
@@ -1017,7 +1017,7 @@ function Add-WorkSheet {
|
|||||||
Adds a workshet to an existing workbook.
|
Adds a workshet to an existing workbook.
|
||||||
.Description
|
.Description
|
||||||
If the named worksheet already exists, the -clearsheet parameter decides whether it should be deleted and a new one returned,
|
If the named worksheet already exists, the -clearsheet parameter decides whether it should be deleted and a new one returned,
|
||||||
or if not specified the existing sheet will be returned.
|
or if not specified the existing sheet will be returned.
|
||||||
#>
|
#>
|
||||||
[cmdletBinding()]
|
[cmdletBinding()]
|
||||||
[OutputType([OfficeOpenXml.ExcelWorksheet])]
|
[OutputType([OfficeOpenXml.ExcelWorksheet])]
|
||||||
@@ -1098,10 +1098,10 @@ function Add-WorkSheet {
|
|||||||
function Add-PivotTable {
|
function Add-PivotTable {
|
||||||
<#
|
<#
|
||||||
.Synopsis
|
.Synopsis
|
||||||
Adds a Pivot table (and optional pivot chart) to a workbook
|
Adds a Pivot table (and optional pivot chart) to a workbook
|
||||||
.Description
|
.Description
|
||||||
If the pivot table already exists, the source data will be updated.
|
If the pivot table already exists, the source data will be updated.
|
||||||
#>
|
#>
|
||||||
param (
|
param (
|
||||||
#Name for the new Pivot table - this will be the name of a sheet in the workbook
|
#Name for the new Pivot table - this will be the name of a sheet in the workbook
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
@@ -1235,8 +1235,8 @@ function Add-ExcelChart {
|
|||||||
#An object representing the worksheet where the chart should be added.
|
#An object representing the worksheet where the chart should be added.
|
||||||
[OfficeOpenXml.ExcelWorksheet]$Worksheet,
|
[OfficeOpenXml.ExcelWorksheet]$Worksheet,
|
||||||
[String]$Title = "Chart Title",
|
[String]$Title = "Chart Title",
|
||||||
#$Header, Not used but referenced previously
|
#$Header, Not used but referenced previously
|
||||||
#The Type of chart (Area, Line, Pie etc)
|
#The Type of chart (Area, Line, Pie etc)
|
||||||
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType = "ColumnStacked",
|
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType = "ColumnStacked",
|
||||||
$XRange,
|
$XRange,
|
||||||
$YRange,
|
$YRange,
|
||||||
@@ -1255,21 +1255,21 @@ function Add-ExcelChart {
|
|||||||
$SeriesHeader,
|
$SeriesHeader,
|
||||||
[Switch]$TitleBold,
|
[Switch]$TitleBold,
|
||||||
[Int]$TitleSize ,
|
[Int]$TitleSize ,
|
||||||
[String]$XAxisTitleText,
|
[String]$XAxisTitleText,
|
||||||
[Switch]$XAxisTitleBold,
|
[Switch]$XAxisTitleBold,
|
||||||
$XAxisTitleSize ,
|
$XAxisTitleSize ,
|
||||||
[string]$XAxisNumberformat,
|
[string]$XAxisNumberformat,
|
||||||
$XMajorUnit,
|
$XMajorUnit,
|
||||||
$XMinorUnit,
|
$XMinorUnit,
|
||||||
$XMaxValue,
|
$XMaxValue,
|
||||||
$XMinValue,
|
$XMinValue,
|
||||||
[OfficeOpenXml.Drawing.Chart.eAxisPosition]$XAxisPosition ,
|
[OfficeOpenXml.Drawing.Chart.eAxisPosition]$XAxisPosition ,
|
||||||
[String]$YAxisTitleText,
|
[String]$YAxisTitleText,
|
||||||
[Switch]$YAxisTitleBold,
|
[Switch]$YAxisTitleBold,
|
||||||
$YAxisTitleSize,
|
$YAxisTitleSize,
|
||||||
[string]$YAxisNumberformat,
|
[string]$YAxisNumberformat,
|
||||||
$YMajorUnit,
|
$YMajorUnit,
|
||||||
$YMinorUnit,
|
$YMinorUnit,
|
||||||
$YMaxValue,
|
$YMaxValue,
|
||||||
$YMinValue,
|
$YMinValue,
|
||||||
[OfficeOpenXml.Drawing.Chart.eAxisPosition]$YAxisPosition )
|
[OfficeOpenXml.Drawing.Chart.eAxisPosition]$YAxisPosition )
|
||||||
@@ -1280,7 +1280,7 @@ function Add-ExcelChart {
|
|||||||
$chart.Title.Text = $Title
|
$chart.Title.Text = $Title
|
||||||
if ($TitleBold) {$chart.Title.Font.Bold = $true}
|
if ($TitleBold) {$chart.Title.Font.Bold = $true}
|
||||||
if ($TitleSize) {$chart.Title.Font.Size = $TitleSize}
|
if ($TitleSize) {$chart.Title.Font.Size = $TitleSize}
|
||||||
}
|
}
|
||||||
if ($NoLegend) { $chart.Legend.Remove() }
|
if ($NoLegend) { $chart.Legend.Remove() }
|
||||||
else {
|
else {
|
||||||
if ($LegendPostion) {$Chart.Legend.Position = $LegendPostion}
|
if ($LegendPostion) {$Chart.Legend.Position = $LegendPostion}
|
||||||
@@ -1293,11 +1293,11 @@ function Add-ExcelChart {
|
|||||||
if ($XAxisTitleBold) {$chart.XAxis.Title.Font.Bold = $true}
|
if ($XAxisTitleBold) {$chart.XAxis.Title.Font.Bold = $true}
|
||||||
if ($XAxisTitleSize) {$chart.XAxis.Title.Font.Size = $XAxisTitleSize}
|
if ($XAxisTitleSize) {$chart.XAxis.Title.Font.Size = $XAxisTitleSize}
|
||||||
}
|
}
|
||||||
if ($XAxisPosition) {$chart.XAxis.AxisPosition = $XAxisPosition}
|
if ($XAxisPosition) {$chart.XAxis.AxisPosition = $XAxisPosition}
|
||||||
if ($XMajorUnit) {$chart.XAxis.MajorUnit = $XMajorUnit}
|
if ($XMajorUnit) {$chart.XAxis.MajorUnit = $XMajorUnit}
|
||||||
if ($XMinorUnit) {$chart.XAxis.MinorUnit = $XMinorUnit}
|
if ($XMinorUnit) {$chart.XAxis.MinorUnit = $XMinorUnit}
|
||||||
if ($XMinValue -ne $null) {$chart.XAxis.MinValue = $XMinValue}
|
if ($null -ne $XMinValue) {$chart.XAxis.MinValue = $XMinValue}
|
||||||
if ($XMaxValue -ne $null) {$chart.XAxis.MaxValue = $XMaxValue}
|
if ($null -ne $XMaxValue) {$chart.XAxis.MaxValue = $XMaxValue}
|
||||||
if ($XAxisNumberformat) {$chart.XAxis.Format = $XAxisNumberformat}
|
if ($XAxisNumberformat) {$chart.XAxis.Format = $XAxisNumberformat}
|
||||||
|
|
||||||
if ($YAxisTitleText) {
|
if ($YAxisTitleText) {
|
||||||
@@ -1306,14 +1306,14 @@ function Add-ExcelChart {
|
|||||||
if ($YAxisTitleSize) {$chart.YAxis.Title.Font.Size = $YAxisTitleSize}
|
if ($YAxisTitleSize) {$chart.YAxis.Title.Font.Size = $YAxisTitleSize}
|
||||||
}
|
}
|
||||||
if ($YAxisPosition) {$chart.YAxis.AxisPosition = $YAxisPosition}
|
if ($YAxisPosition) {$chart.YAxis.AxisPosition = $YAxisPosition}
|
||||||
if ($YMajorUnit) {$chart.YAxis.MajorUnit = $YMajorUnit}
|
if ($YMajorUnit) {$chart.YAxis.MajorUnit = $YMajorUnit}
|
||||||
if ($YMinorUnit) {$chart.YAxis.MinorUnit = $YMinorUnit}
|
if ($YMinorUnit) {$chart.YAxis.MinorUnit = $YMinorUnit}
|
||||||
if ($YMinValue-ne $null) {$chart.YAxis.MinValue = $YMinValue}
|
if ($null -ne $YMinValue){$chart.YAxis.MinValue = $YMinValue}
|
||||||
if ($YMaxValue-ne $null) {$chart.YAxis.MaxValue = $YMaxValue}
|
if ($null -ne $YMaxValue){$chart.YAxis.MaxValue = $YMaxValue}
|
||||||
if ($YAxisNumberformat) {$chart.YAxis.Format = $YAxisNumberformat}
|
if ($YAxisNumberformat) {$chart.YAxis.Format = $YAxisNumberformat}
|
||||||
if ($chart.Datalabel -ne $null) {
|
if ($null -ne $chart.Datalabel) {
|
||||||
$chart.Datalabel.ShowCategory = [boolean]$ShowCategory
|
$chart.Datalabel.ShowCategory = [boolean]$ShowCategory
|
||||||
$chart.Datalabel.ShowPercent = [boolean]$ShowPercent
|
$chart.Datalabel.ShowPercent = [boolean]$ShowPercent
|
||||||
}
|
}
|
||||||
|
|
||||||
$chart.SetPosition($Row, $RowOffsetPixels, $Column, $ColumnOffsetPixels)
|
$chart.SetPosition($Row, $RowOffsetPixels, $Column, $ColumnOffsetPixels)
|
||||||
|
|||||||
@@ -129,7 +129,7 @@
|
|||||||
if ($VerticalAlignment) { $worksheet.row( $Row ).Style.VerticalAlignment = $VerticalAlignment }
|
if ($VerticalAlignment) { $worksheet.row( $Row ).Style.VerticalAlignment = $VerticalAlignment }
|
||||||
if ($Height) { $worksheet.row( $Row ).Height = $Height }
|
if ($Height) { $worksheet.row( $Row ).Height = $Height }
|
||||||
if ($FontColor) { $worksheet.row( $Row ).Style.Font.Color.SetColor( $FontColor ) }
|
if ($FontColor) { $worksheet.row( $Row ).Style.Font.Color.SetColor( $FontColor ) }
|
||||||
if ($BorderAround) { $worksheet.row( $Row ).Style.Border.BorderAround( $BorderAround ) }
|
if ($BorderAround) { $worksheet.row( $Row ).Style.Border.BorderAround( $BorderAround ) }
|
||||||
if ($BackgroundColor) {
|
if ($BackgroundColor) {
|
||||||
$worksheet.row( $Row ).Style.Fill.PatternType = $BackgroundPattern
|
$worksheet.row( $Row ).Style.Fill.PatternType = $BackgroundPattern
|
||||||
$worksheet.row( $Row ).Style.Fill.BackgroundColor.SetColor($BackgroundColor )
|
$worksheet.row( $Row ).Style.Fill.BackgroundColor.SetColor($BackgroundColor )
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
begin {
|
begin {
|
||||||
#Allow Set-Format to take Worksheet and range parameters (like Add Contitional formatting) - convert them to an address
|
#Allow Set-Format to take Worksheet and range parameters (like Add Contitional formatting) - convert them to an address
|
||||||
if ($WorkSheet -and $Range) {$Address = $WorkSheet.Cells[$Range] }
|
if ($WorkSheet -and $Range) {$Address = $WorkSheet.Cells[$Range] }
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
if ($Address -is [Array]) {
|
if ($Address -is [Array]) {
|
||||||
@@ -113,29 +113,29 @@
|
|||||||
if ($HorizontalAlignment) {$Address.Style.HorizontalAlignment = $HorizontalAlignment }
|
if ($HorizontalAlignment) {$Address.Style.HorizontalAlignment = $HorizontalAlignment }
|
||||||
if ($VerticalAlignment) {$Address.Style.VerticalAlignment = $VerticalAlignment }
|
if ($VerticalAlignment) {$Address.Style.VerticalAlignment = $VerticalAlignment }
|
||||||
if ($Value) {$Address.Value = $Value }
|
if ($Value) {$Address.Value = $Value }
|
||||||
if ($Formula) {$Address.Formula = $Formula }
|
if ($Formula) {$Address.Formula = $Formula }
|
||||||
if ($BorderAround) {$Address.Style.Border.BorderAround($BorderAround, $BorderColor)}
|
if ($BorderAround) {$Address.Style.Border.BorderAround($BorderAround, $BorderColor)}
|
||||||
|
|
||||||
if ($BorderBottom) {
|
if ($BorderBottom) {
|
||||||
$Address.Style.Border.Bottom.Style=$BorderBottom
|
$Address.Style.Border.Bottom.Style=$BorderBottom
|
||||||
$Address.Style.Border.Bottom.Color.SetColor($BorderColor)
|
$Address.Style.Border.Bottom.Color.SetColor($BorderColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($BorderTop) {
|
if ($BorderTop) {
|
||||||
$Address.Style.Border.Top.Style=$BorderTop
|
$Address.Style.Border.Top.Style=$BorderTop
|
||||||
$Address.Style.Border.Top.Color.SetColor($BorderColor)
|
$Address.Style.Border.Top.Color.SetColor($BorderColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($BorderLeft) {
|
if ($BorderLeft) {
|
||||||
$Address.Style.Border.Left.Style=$BorderLeft
|
$Address.Style.Border.Left.Style=$BorderLeft
|
||||||
$Address.Style.Border.Left.Color.SetColor($BorderColor)
|
$Address.Style.Border.Left.Color.SetColor($BorderColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($BorderRight) {
|
if ($BorderRight) {
|
||||||
$Address.Style.Border.Right.Style=$BorderRight
|
$Address.Style.Border.Right.Style=$BorderRight
|
||||||
$Address.Style.Border.Right.Color.SetColor($BorderColor)
|
$Address.Style.Border.Right.Color.SetColor($BorderColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($BackgroundColor) {
|
if ($BackgroundColor) {
|
||||||
$Address.Style.Fill.PatternType = $BackgroundPattern
|
$Address.Style.Fill.PatternType = $BackgroundPattern
|
||||||
$Address.Style.Fill.BackgroundColor.SetColor($BackgroundColor)
|
$Address.Style.Fill.BackgroundColor.SetColor($BackgroundColor)
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
if ($Autosize) {
|
if ($Autosize) {
|
||||||
if ($Address -is [OfficeOpenXml.ExcelColumn]) {$Address.AutoFit() }
|
if ($Address -is [OfficeOpenXml.ExcelColumn]) {$Address.AutoFit() }
|
||||||
elseif ($Address -is [OfficeOpenXml.ExcelRange] ) {
|
elseif ($Address -is [OfficeOpenXml.ExcelRange] ) {
|
||||||
$Address.AutoFitColumns()
|
$Address.AutoFitColumns()
|
||||||
}
|
}
|
||||||
else {Write-Warning -Message ("Can autofit a column or a range but not a {0} object" -f ($Address.GetType().name)) }
|
else {Write-Warning -Message ("Can autofit a column or a range but not a {0} object" -f ($Address.GetType().name)) }
|
||||||
|
|
||||||
|
|||||||
2
ToDo.md
2
ToDo.md
@@ -7,3 +7,5 @@
|
|||||||
[ ] Copy parameter help from function Add-ExcelChart into New-ExcelChart.ps1
|
[ ] Copy parameter help from function Add-ExcelChart into New-ExcelChart.ps1
|
||||||
- [ ] Examples and tests for new "Quick charts" in Export Excel
|
- [ ] Examples and tests for new "Quick charts" in Export Excel
|
||||||
- [ ] Charting.ps1,GetXYRange.ps1, InferData.PS1 move to deprecated. (replace examples)
|
- [ ] Charting.ps1,GetXYRange.ps1, InferData.PS1 move to deprecated. (replace examples)
|
||||||
|
- [ ] Refactor Set-Row and Set-Column to use set-format and add conditional format support.
|
||||||
|
- [ ] Examples and tests for set-Row and Set-column; review test coverage and examples for Set-Format adn Add-Conditional formatting
|
||||||
Reference in New Issue
Block a user