From 9cb16c12a34ef32f33001d83ff2eef9f7ee1389a Mon Sep 17 00:00:00 2001 From: Doug Finke Date: Fri, 10 Apr 2015 14:19:22 -0400 Subject: [PATCH] Exposed ability to set a password on the sheet --- .gitignore | 2 ++ ImportExcel.psm1 | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 21fb51f..65d2833 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,5 @@ InstallModule.ps1 Export-Excel.ps1 testExport.xlsx test.ps1 +testPwd.xlsx +test.csv diff --git a/ImportExcel.psm1 b/ImportExcel.psm1 index fc0867a..f583df2 100644 --- a/ImportExcel.psm1 +++ b/ImportExcel.psm1 @@ -53,6 +53,7 @@ function Export-Excel { [string[]]$PivotRows, [string[]]$PivotColumns, [string[]]$PivotData, + [string]$Password, [OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="Pie", [Switch]$IncludePivotTable, [Switch]$IncludePivotChart, @@ -137,6 +138,7 @@ function Export-Excel { } } + $ws.Protection.SetPassword($Password) $pkg.Save() $pkg.Dispose() @@ -151,6 +153,7 @@ function Export-MultipleExcelSheets { $Path, [Parameter(Mandatory)] [hashtable]$InfoMap, + [string]$Password, [Switch]$Show, [Switch]$AutoSize )