Updates after proof reading help

This commit is contained in:
jhoneill
2018-10-17 11:23:15 +01:00
parent d26f0c66dd
commit 61173d5e40
11 changed files with 386 additions and 265 deletions

View File

@@ -1,19 +1,22 @@
Function Open-ExcelPackage {
<#
.Synopsis
Returns an Excel Package Object for the specified XLSX file
Returns an ExcelPackage object for the specified XLSX fil.e
.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.
Sometimes it is necessary to open a file and do other work on it.
Open-ExcelPackage 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
>
PS> $excel = Open-ExcelPackage -Path "$env:TEMP\test99.xlsx" -Create
$ws = Add-WorkSheet -ExcelPackage $excel
This will create a new file in the temp folder if it doesn't already exist. It then adds a worksheet -
because no name is specified it will use the default name of "Sheet1"
This will create a new file in the temp folder if it doesn't already exist.
It then adds a worksheet - because no name is specified it will use the
default name of "Sheet1"
.Example
>
PS> $excel = Open-ExcelPackage -path "$xlPath" -Password $password
@@ -21,20 +24,21 @@
Set-ExcelRange -Range $sheet1.Cells["E1:S1048576"], $sheet1.Cells["V1:V1048576"] -NFormat ([cultureinfo]::CurrentCulture.DateTimeFormat.ShortDatePattern)
Close-ExcelPackage $excel -Show
This will open the password protected file at $xlPath using the password stored in $Password.
Sheet1 is selected and formatting applied to two blocks of the sheet; then the file is and saved and loaded into Excel.
This will open the password protected file at $xlPath using the password stored
in $Password. Sheet1 is selected and formatting applied to two blocks of the sheet;
then the file is and saved and loaded into Excel.
#>
[CmdLetBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword","")]
[OutputType([OfficeOpenXml.ExcelPackage])]
Param (
#The Path to the file to open
#The path to the file to open.
[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.)
#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.
#By default Open-ExcelPackage will only opens an existing file; -Create instructs it to create a new file if required.
[switch]$Create
)
@@ -75,7 +79,7 @@ Function Close-ExcelPackage {
.Description
When working with an ExcelPackage object, the Workbook is held in memory and not saved until the .Save() method of the package is called.
Close-ExcelPackage saves and disposes of the Package object. It can be called with -NoSave to abandon the file without saving, with a new "SaveAs" filename,
and/or with a password to protect the file. And -Show will open the file in Excel;
and/or with a password to protect the file. And -Show will open the file in Excel;
-Calculate will try to update the workbook, although not everything can be recalculated
.Example
Close-ExcelPackage -show $excel