From 6393701a2fed5e69e7490702982136830432ad3a Mon Sep 17 00:00:00 2001 From: jhoneill Date: Wed, 5 Sep 2018 11:44:41 +0100 Subject: [PATCH] Further updates to on-line help --- Export-Excel.ps1 | 5 ++++- Open-ExcelPackage.ps1 | 8 +++++++- PivotTable.ps1 | 4 +++- Set-Column.ps1 | 1 + Set-Row.ps1 | 1 + SetFormat.ps1 | 7 +++++++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index c339531..e19881a 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -1142,7 +1142,10 @@ function Add-WorkSheet { function Select-Worksheet { <# .SYNOPSIS - Sets the selected tab in an Excel workbook to be a Particular sheet, and unselects all the others. + Sets the selected tab in an Excel workbook to be the chosen sheet, and unselects all the others. + .DESCRIPTION + Sometimes when a sheet is added we want it to be the active sheet, sometimes we want the active sheet to be left as it was. + Select-Worksheet exists to change the which sheet is the selected tab when Excel opens the file. .EXAMPLE Select-Worksheet -ExcelWorkbook $ExcelWorkbook -WorksheetName "NewSheet" $ExcelWorkbook holds the a workbook object containing a sheet named "NewSheet"; diff --git a/Open-ExcelPackage.ps1 b/Open-ExcelPackage.ps1 index ff76581..0e756c9 100644 --- a/Open-ExcelPackage.ps1 +++ b/Open-ExcelPackage.ps1 @@ -1,7 +1,12 @@ Function Open-ExcelPackage { <# .Synopsis - Returns an Excel Package Object with for the specified XLSX ile + Returns an Excel Package Object for the specified XLSX file +.Description + Import-Excel and Export-Excel open an Excel file, carry out their tasks and close it again. + Sometimes it is necessary to open a file and do other work on it. Open-Excel package allows the file to be opened for these tasks. + It takes a KillExcel switch to make sure Excel is not holding the file open; a password parameter for existing protected files, + and a create switch to set-up a new file if no file already exists. .Example $excel = Open-ExcelPackage -path $xlPath $sheet1 = $excel.Workbook.Worksheets["sheet1"] @@ -18,6 +23,7 @@ [Parameter(Mandatory=$true)]$Path, #If specified, any running instances of Excel will be terminated before opening the file. [switch]$KillExcel, + #The password for a protected worksheet, as a [normal] string (not a secure string.) [String]$Password, #By default open only opens an existing file; -Create instructs it to create a new file if required. [switch]$Create diff --git a/PivotTable.ps1 b/PivotTable.ps1 index 79c901b..2485e2a 100644 --- a/PivotTable.ps1 +++ b/PivotTable.ps1 @@ -54,7 +54,7 @@ $PivotColumns, #Fields to use to filter in the Pivot table $PivotFilter, - #By default Pivot tables have Totals for each Row (on the right) and for each column at the bottom. This allows just one or neither to be selected. + #If there are multiple datasets in a PivotTable, by default they are shown seperatate rows under the given row heading; this switch makes them seperate columns. [Switch]$PivotDataToColumn, #Define whther totals should be added to rows, columns neither, or both (the default is both) [ValidateSet("Both","Columns","Rows","None")] @@ -233,8 +233,10 @@ function New-PivotTableDefinition { $PivotColumns, #Fields to use to filter in the Pivot table $PivotFilter, + #If there are multiple datasets in a PivotTable, by default they are shown seperatate rows under the given row heading; this switch makes them seperate columns. [Switch]$PivotDataToColumn, #By default Pivot tables have Totals for each Row (on the right) and for each column at the bottom. This allows just one or neither to be selected. + #Define whther totals should be added to rows, columns neither, or both (the default is both) [ValidateSet("Both","Columns","Rows","None")] [String]$PivotTotals = "Both", #Included for compatibility - equivalent to -PivotTotals "None" diff --git a/Set-Column.ps1 b/Set-Column.ps1 index cfb6007..9a416ac 100644 --- a/Set-Column.ps1 +++ b/Set-Column.ps1 @@ -23,6 +23,7 @@ When given a valid URI set-Column makes it a hyperlink The column will be autosized to fit the links. #> [cmdletbinding()] + [OutputType([OfficeOpenXml.ExcelColumn],[String])] Param ( #If specifing the worksheet by name the ExcelPackage object which contains it needs to be passed [Parameter(ParameterSetName="Package",Mandatory=$true)] diff --git a/Set-Row.ps1 b/Set-Row.ps1 index 3b67b16..ca3d104 100644 --- a/Set-Row.ps1 +++ b/Set-Row.ps1 @@ -17,6 +17,7 @@ The script block can use $row, $column, $ColumnName, $startRow/Column $endRow/Column #> [cmdletbinding()] + [OutputType([OfficeOpenXml.ExcelRow],[String])] Param ( #An Excel package object - e.g. from Export-Excel -passthru - requires a sheet name [Parameter(ParameterSetName="Package",Mandatory=$true)] diff --git a/SetFormat.ps1 b/SetFormat.ps1 index 1407a77..1e5c658 100644 --- a/SetFormat.ps1 +++ b/SetFormat.ps1 @@ -2,6 +2,12 @@ <# .SYNOPSIS Applies Number, font, alignment and colour formatting to a range of Excel Cells + .DESCRIPTION + Set-Format was created to set the style elements for a range of cells, this includes autosizing and hiding, setting + font elements (Name, Size, Bold, Italic, Underline & UnderlineStyle and Subscript & SuperScript), font and background colors, + borders, text wrapping, rotation, aliginment within cells, and number format. + It has been extended to set Values, Formulas and set ArrayFormulas (sometimes called Ctrl-shift-Enter [CSE] formulas); because of this + it has an alias of Set-ExcelRange - in the future the Alias and Canonical name may swapped. .EXAMPLE $sheet.Column(3) | Set-Format -HorizontalAlignment Right -NumberFormat "#,###" Selects column 3 from a sheet object (within a workbook object, which is a child of the ExcelPackage object) and passes it to Set-Format which formats as an integer with comma seperated groups @@ -9,6 +15,7 @@ Set-Format -Address $sheet.Cells["E1:H1048576"] -HorizontalAlignment Right -NumberFormat "#,###" Instead of piping the address in this version specifies a block of cells and applies similar formatting #> + [cmdletbinding()] Param ( #One or more row(s), Column(s) and/or block(s) of cells to format [Parameter(ValueFromPipeline = $true,ParameterSetName="Address",Mandatory=$True,Position=0)]