From 658a6b543a085521993b8b39fb5c1a5fa34a6724 Mon Sep 17 00:00:00 2001 From: Kinga Kazala Date: Mon, 20 Jun 2022 17:12:48 +0200 Subject: [PATCH 01/11] docs: Highlight-DiffCells.ps1 example added --- .../Highlight-DiffCells.ps1 | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Examples/ConditionalFormatting/Highlight-DiffCells.ps1 diff --git a/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 b/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 new file mode 100644 index 0000000..d64d0ef --- /dev/null +++ b/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 @@ -0,0 +1,28 @@ +try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return } +#Get rid of pre-exisiting sheet +$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" + + +Write-Verbose -Verbose -Message "Save location: $xlSourcefile" +Remove-Item $xlSourcefile -ErrorAction Ignore + +$data = ConvertFrom-Csv @" +Region,State,Units2021,Units2022 +West,Texas,927,925 +North,Tennessee,466,466 +East,Florida,520,458 +East,Maine,828,661 +West,Virginia,465,465 +North,Missouri,436,235 +South,Kansas,214,214 +North,North Dakota,789,640 +South,Delaware,712,508 +"@ + + + +$excel = $data | Export-Excel $xlSourcefile -AutoSize -PassThru + +Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "C2:D10" -ConditionValue '=C2=D2' -RuleType Expression -BackgroundColor Cyan + +Close-ExcelPackage $excel -Show \ No newline at end of file From 632bb263cce46d81affc9e4205291438534c5441 Mon Sep 17 00:00:00 2001 From: Kinga Kazala Date: Mon, 20 Jun 2022 17:12:48 +0200 Subject: [PATCH 02/11] docs: Highlight-DiffCells.ps1 example added --- .../Highlight-DiffCells.ps1 | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Examples/ConditionalFormatting/Highlight-DiffCells.ps1 diff --git a/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 b/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 new file mode 100644 index 0000000..d6ddf31 --- /dev/null +++ b/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 @@ -0,0 +1,28 @@ +try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return } +#Get rid of pre-exisiting sheet +$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" + + +Write-Verbose -Verbose -Message "Save location: $xlSourcefile" +Remove-Item $xlSourcefile -ErrorAction Ignore + +$data = ConvertFrom-Csv @" +Region,State,Units2021,Units2022 +West,Texas,927,925 +North,Tennessee,466,466 +East,Florida,520,458 +East,Maine,828,661 +West,Virginia,465,465 +North,Missouri,436,235 +South,Kansas,214,214 +North,North Dakota,789,640 +South,Delaware,712,508 +"@ + + + +$excel = $data | Export-Excel $xlSourcefile -AutoSize -PassThru + +Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "C2:C10" -ConditionValue '=C2=D2' -RuleType Expression -BackgroundColor Cyan + +Close-ExcelPackage $excel -Show \ No newline at end of file From d7348250fc201e55c546bbffacc9a039e0a8a1bf Mon Sep 17 00:00:00 2001 From: Doug Finke Date: Mon, 20 Jun 2022 13:00:33 -0400 Subject: [PATCH 03/11] Updated --- Examples/ConditionalFormatting/Highlight-DiffCells.ps1 | 5 ++--- changelog.md | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 b/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 index a4852c3..4cbffac 100644 --- a/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 +++ b/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 @@ -1,7 +1,7 @@ try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return } -#Get rid of pre-exisiting sheet -$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" +# Get rid of pre-exisiting sheet +$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" Write-Verbose -Verbose -Message "Save location: $xlSourcefile" Remove-Item $xlSourcefile -ErrorAction Ignore @@ -19,7 +19,6 @@ North,North Dakota,789,640 South,Delaware,712,508 "@ - $excel = $data | Export-Excel $xlSourcefile -AutoSize -PassThru Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "C2:C10" -ConditionValue '=C2=D2' -RuleType Expression -BackgroundColor Cyan diff --git a/changelog.md b/changelog.md index 4260b7f..5d85a1b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +# Example added + +Thank you [@kkazala](https://github.com/kkazala) +- Added an example showing `ConditionalFormatting` using the `RuleType` `Expression` with a formula + - [Highlight-DiffCells.ps1](https://github.dev/kkazala/ImportExcel/blob/b53881fd023c052da1acc7812511da223bb2e40c/Examples/ConditionalFormatting/Highlight-DiffCells.ps1) + # 7.6.0 - **_[Under investigation]_** Fix -StartRow and -StartColumn being ignored. From f2544ed1ec02b9203e7290e75eef42ae79726fa3 Mon Sep 17 00:00:00 2001 From: dfinke Date: Mon, 4 Jul 2022 10:29:39 -0400 Subject: [PATCH 04/11] Fix -UnderLineType parameter is ignored in Set-ExcelColumn #1204 --- ImportExcel.psd1 | 2 +- Public/Set-ExcelColumn.ps1 | 2 +- __tests__/Export-Excel.Tests.ps1 | 69 +++++++++++++++++++++++++++----- changelog.md | 4 ++ 4 files changed, 66 insertions(+), 11 deletions(-) diff --git a/ImportExcel.psd1 b/ImportExcel.psd1 index 9b4e0e0..7349648 100644 --- a/ImportExcel.psd1 +++ b/ImportExcel.psd1 @@ -6,7 +6,7 @@ RootModule = 'ImportExcel.psm1' # Version number of this module. - ModuleVersion = '7.6.0' + ModuleVersion = '7.7.0' # ID used to uniquely identify this module GUID = '60dd4136-feff-401a-ba27-a84458c57ede' diff --git a/Public/Set-ExcelColumn.ps1 b/Public/Set-ExcelColumn.ps1 index 6ff5e6f..46133ed 100644 --- a/Public/Set-ExcelColumn.ps1 +++ b/Public/Set-ExcelColumn.ps1 @@ -110,7 +110,7 @@ #region Apply formatting $params = @{} - foreach ($p in @('Underline','Bold','Italic','StrikeThru', 'FontName', 'FontSize','FontShift','NumberFormat','TextRotation', + foreach ($p in @('Underline','UnderLineType','Bold','Italic','StrikeThru', 'FontName', 'FontSize','FontShift','NumberFormat','TextRotation', 'WrapText', 'HorizontalAlignment','VerticalAlignment', 'Autosize', 'Width', 'FontColor' 'BorderAround', 'BackgroundColor', 'BackgroundPattern', 'PatternColor')) { if ($PSBoundParameters.ContainsKey($p)) {$params[$p] = $PSBoundParameters[$p]} diff --git a/__tests__/Export-Excel.Tests.ps1 b/__tests__/Export-Excel.Tests.ps1 index e778840..21a0644 100644 --- a/__tests__/Export-Excel.Tests.ps1 +++ b/__tests__/Export-Excel.Tests.ps1 @@ -1,6 +1,6 @@ #Requires -Modules Pester -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments','',Justification='False Positives')] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable','',Justification='Only executes on versions without the automatic variable')] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'False Positives')] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '', Justification = 'Only executes on versions without the automatic variable')] param() Describe ExportExcel -Tag "ExportExcel" { BeforeAll { @@ -8,7 +8,7 @@ Describe ExportExcel -Tag "ExportExcel" { $WarningAction = "SilentlyContinue" . "$PSScriptRoot\Samples\Samples.ps1" if (-not (Get-command Get-Service -ErrorAction SilentlyContinue)) { - Function Get-Service {Import-Clixml $PSScriptRoot\Mockservices.xml} + Function Get-Service { Import-Clixml $PSScriptRoot\Mockservices.xml } } if (Get-process -Name Excel, xlim -ErrorAction SilentlyContinue) { It "Excel is open" { @@ -389,7 +389,7 @@ Describe ExportExcel -Tag "ExportExcel" { } } - Context "#Example 5 # Adding a single conditional format "{ + Context "#Example 5 # Adding a single conditional format " { BeforeEach { #Test New-ConditionalText builds correctly $ct = New-ConditionalText -ConditionalType GreaterThan 525 -ConditionalTextColor ([System.Drawing.Color]::DarkRed) -BackgroundColor ([System.Drawing.Color]::LightPink) @@ -491,7 +491,7 @@ Describe ExportExcel -Tag "ExportExcel" { } } - Context "#Examples 8 & 9 # Adding Pivot tables and charts from parameters" { + Context "#Examples 8 & 9 # Adding Pivot tables and charts from parameters" { BeforeAll { $path = "TestDrive:\test.xlsx" #Test -passthru and -worksheetName creating a new, named, sheet in an existing file. @@ -544,7 +544,7 @@ Describe ExportExcel -Tag "ExportExcel" { #Test appending data extends pivot chart (with a warning) . $warnVar = $null Get-Process | Select-Object -Last 20 -Property Name, cpu, pm, handles, company | - Export-Excel $path -WorkSheetname Processes -Append -IncludePivotTable -PivotRows Company -PivotData PM -IncludePivotChart -ChartType PieExploded3D -WarningAction SilentlyContinue -WarningVariable warnvar + Export-Excel $path -WorkSheetname Processes -Append -IncludePivotTable -PivotRows Company -PivotData PM -IncludePivotChart -ChartType PieExploded3D -WarningAction SilentlyContinue -WarningVariable warnvar $Excel = Open-ExcelPackage $path $pt = $Excel.Workbook.Worksheets["ProcessesPivotTable"].PivotTables[0] @@ -557,12 +557,12 @@ Describe ExportExcel -Tag "ExportExcel" { } } - Context " # Add-Worksheet inserted sheets, moved them correctly, and copied a sheet" { + Context " # Add-Worksheet inserted sheets, moved them correctly, and copied a sheet" { BeforeAll { $path = "TestDrive:\test.xlsx" #Test the -CopySource and -Movexxxx parameters for Add-Worksheet $Excel = Get-Process | Select-Object -first 20 -Property Name, cpu, pm, handles, company | - Export-Excel $path -WorkSheetname Processes -IncludePivotTable -PivotRows Company -PivotData PM -NoTotalsInPivot -PivotDataToColumn -Activate + Export-Excel $path -WorkSheetname Processes -IncludePivotTable -PivotRows Company -PivotData PM -NoTotalsInPivot -PivotDataToColumn -Activate $Excel = Open-ExcelPackage $path #At this point Sheets Should be in the order Sheet1, Processes, ProcessesPivotTable @@ -1081,4 +1081,55 @@ Describe ExportExcel -Tag "ExportExcel" { } } } -} + + Context " # Check UnderLineType" -Tag CheckUnderLineType { + BeforeAll { + $Path = Join-Path (Resolve-Path 'TestDrive:').ProviderPath "testUnderLineType.xlsx" + Remove-Item -Path $Path -ErrorAction SilentlyContinue + + $data = " + Set-ExcelRange,Set-ExcelColumn + Should be double underlined,Should be double underlined + Should be double underlined,Should be double underlined + " | ConvertFrom-Csv + + $data | Export-Excel $Path -AutoSize + + $excel = Open-ExcelPackage $Path + $ws = $excel.Workbook.Worksheets["sheet1"] + + Set-ExcelRange -Range $ws.Cells["A2:A3"] -Underline -UnderLineType "Double" + Set-ExcelColumn -Worksheet $ws -Column 2 -StartRow 2 -Underline -UnderLineType "Double" + + Close-ExcelPackage $excel + } + + AfterAll { + Remove-Item -Path $Path -ErrorAction SilentlyContinue + } + + it "Check Cell Style Font via Set-ExcelColumn".PadRight(87) { + $excel = Open-ExcelPackage $Path + $cell = $excel.Sheet1.Cells["B2"] + + $actual = $cell.Style.Font + + $actual.Underline | Should -BeTrue + $actual.UnderlineType | Should -Be "Double" + + Close-ExcelPackage $excel -NoSave + } + + it "Check Cell Style Font via Set-ExcelRange".PadRight(87) { + $excel = Open-ExcelPackage $Path + $cell = $excel.Sheet1.Cells["A2"] + + $actual = $cell.Style.Font + + $actual.Underline | Should -BeTrue + $actual.UnderlineType | Should -Be "Double" + + Close-ExcelPackage $excel -NoSave + } + } +} \ No newline at end of file diff --git a/changelog.md b/changelog.md index 64fab5a..cc5548b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +# 7.7.0 + +- Fix a bug with `-UnderLineType parameter is ignored in Set-ExcelColumn` [#1204](https://github.com/dfinke/ImportExcel/issues/1204) + # 7.6.0 - **_[Under investigation]_** Fix -StartRow and -StartColumn being ignored. From 9051ffc0e55bcbc6d4ab07a6a81108ebaca9ba79 Mon Sep 17 00:00:00 2001 From: Kinga Kazala Date: Tue, 5 Jul 2022 15:59:32 +0200 Subject: [PATCH 05/11] example update: format both cells, plus format whole row --- Examples/ConditionalFormatting/Highlight-DiffCells.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 b/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 index 4cbffac..29f90a6 100644 --- a/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 +++ b/Examples/ConditionalFormatting/Highlight-DiffCells.ps1 @@ -1,6 +1,5 @@ try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return } -# Get rid of pre-exisiting sheet $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" Write-Verbose -Verbose -Message "Save location: $xlSourcefile" @@ -21,6 +20,7 @@ South,Delaware,712,508 $excel = $data | Export-Excel $xlSourcefile -AutoSize -PassThru -Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "C2:C10" -ConditionValue '=C2=D2' -RuleType Expression -BackgroundColor Cyan +Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "C2:D10" -ConditionValue '=$C2=$D2' -RuleType Expression -BackgroundColor ([System.Drawing.Color]::Thistle) -Bold +Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "A2:D10" -ConditionValue '=$C2=$D2' -RuleType Expression -BackgroundColor ([System.Drawing.Color]::LavenderBlush) Close-ExcelPackage $excel -Show \ No newline at end of file From c4eed8c25d5e16b87d9eaaca6dd347d02c52b140 Mon Sep 17 00:00:00 2001 From: Kinga Kazala Date: Tue, 5 Jul 2022 16:05:40 +0200 Subject: [PATCH 06/11] GetConditionalFormatting.ps1 example added: exports conditional formatting rules in a 'ready to use' format --- .../ConditionalFormatting/GetConditionalFormatting.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Examples/ConditionalFormatting/GetConditionalFormatting.ps1 diff --git a/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 b/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 new file mode 100644 index 0000000..b25d031 --- /dev/null +++ b/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 @@ -0,0 +1,10 @@ +try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return} + +$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" +$excel = Open-ExcelPackage -Path $xlSourcefile + +$excel.Workbook.Worksheets | ForEach-Object { + $_.ConditionalFormatting | ForEach-Object { + Write-Host "Add-ConditionalFormatting -Worksheet `$excel[""$worksheetName""] -Range '$($_.Address)' -ConditionValue '$($_.Formula)' -RuleType $($_.Type) " + } +} From b92ea56fe9fa563a8a8ed541a3fb09cc4e10fbe4 Mon Sep 17 00:00:00 2001 From: Kinga Kazala Date: Mon, 11 Jul 2022 07:58:29 +0200 Subject: [PATCH 07/11] GetConditionalFormatting.xlsx added --- .../GetConditionalFormatting.xlsx | Bin 0 -> 8999 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Examples/ConditionalFormatting/GetConditionalFormatting.xlsx diff --git a/Examples/ConditionalFormatting/GetConditionalFormatting.xlsx b/Examples/ConditionalFormatting/GetConditionalFormatting.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..bfa1cba7e4c1331d4f28d4c0e3255b742f35b780 GIT binary patch literal 8999 zcmeHNg;!PE_C9pu0i?T2LJ&a&l#q@?!=Y31&|Lyj0@5vwboT)cEg+qWv~-7nH2jXf z`=0lD@9!^oZ=Esr8fT0>=h%C$@0)Y3Z*7nq67qcjDgYe-0MG)A_tP!(5deT_WB`Bw zfR3mmZU=ETgE$+gdDxpd>2bQ-+R)@6BeG-x5aIX#Z~PZWpfr9!v5On{;!OHle3e6X zuKGDT-(Em3KAW;gdv{z9os8%Hv;pJO0FZTfEm0W{WW=ZY8DXycz+orN{1xL@0*dZMa?_@asAy9~ z5<1%lOYeI#B$S@;vjzAT^nGj;Xjj@Zq40*}kD;w1zc|0U{~d3u>9}1C__3Xq!6#&I zsc-A4*Y4<=PT>Ag;+7xJEh+$TcZUQ3{e_lw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IYRJ7?3AO$6cbD;$)eq2*w+@?(ZY;ln+oLDwPYVV$eJINs+#yEm> z`YO6>E+8^*sxJ)>CqygyCSkdS=z|i?U~&QpE%@-AeT@wye+H*p`B})h7$sd?tPJ

>h~Pv3L(l>*dsF>5-oV~LVN>&!wu5olUn`-s-O=`KGo(^%qO~@0oda ze~|xp9P+8{KV23AA_u&x{PQOX|6Z_v&;Rg&0!Z$!4*q(0`ftM@a}t~te>zJ2-SGDV zrC+8k@Sg9t Date: Wed, 13 Jul 2022 09:26:00 +0200 Subject: [PATCH 08/11] fix: corrected the script to include sheet name, and to add '=' in the ConditionValue --- .../ConditionalFormatting/GetConditionalFormatting.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 b/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 index b25d031..4f2e763 100644 --- a/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 +++ b/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 @@ -1,10 +1,13 @@ try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return} -$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" +# This example is using Excel generated by Highlight-DiffCells.ps1 +# The displayed rule should be the same as in the PS script +$xlSourcefile = "$env:TEMP.\GetConditionalFormatting.xlsx" $excel = Open-ExcelPackage -Path $xlSourcefile $excel.Workbook.Worksheets | ForEach-Object { + $wsNme= $_.Name $_.ConditionalFormatting | ForEach-Object { - Write-Host "Add-ConditionalFormatting -Worksheet `$excel[""$worksheetName""] -Range '$($_.Address)' -ConditionValue '$($_.Formula)' -RuleType $($_.Type) " + "Add-ConditionalFormatting -Worksheet `$excel[""$wsNme""] -Range '$($_.Address)' -ConditionValue '=$($_.Formula)' -RuleType $($_.Type) " } } From 724ed6b197c345ef906bf85aad616674e8e52989 Mon Sep 17 00:00:00 2001 From: Kinga Kazala Date: Wed, 13 Jul 2022 09:34:30 +0200 Subject: [PATCH 09/11] Get-ConditionalFormatting function added --- .../GetConditionalFormatting.ps1 | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 b/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 index 4f2e763..a9bc3a9 100644 --- a/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 +++ b/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 @@ -2,12 +2,20 @@ # This example is using Excel generated by Highlight-DiffCells.ps1 # The displayed rule should be the same as in the PS script -$xlSourcefile = "$env:TEMP.\GetConditionalFormatting.xlsx" -$excel = Open-ExcelPackage -Path $xlSourcefile -$excel.Workbook.Worksheets | ForEach-Object { - $wsNme= $_.Name - $_.ConditionalFormatting | ForEach-Object { - "Add-ConditionalFormatting -Worksheet `$excel[""$wsNme""] -Range '$($_.Address)' -ConditionValue '=$($_.Formula)' -RuleType $($_.Type) " +function Get-ConditionalFormatting { + param ( + [string] $xlSourcefile + ) + $excel = Open-ExcelPackage -Path $xlSourcefile + + $excel.Workbook.Worksheets | ForEach-Object { + $wsNme = $_.Name + $_.ConditionalFormatting | ForEach-Object { + "Add-ConditionalFormatting -Worksheet `$excel[""$wsNme""] -Range '$($_.Address)' -ConditionValue '=$($_.Formula)' -RuleType $($_.Type) " + } } } + +$xlSourcefile = "$env:TEMP.\GetConditionalFormatting.xlsx" +Get-ConditionalFormatting -xlSourcefile $xlSourcefile \ No newline at end of file From 0990c0ef091921dd83e3f1b29b0e4925be77fb34 Mon Sep 17 00:00:00 2001 From: dfinke Date: Wed, 13 Jul 2022 09:50:02 -0400 Subject: [PATCH 10/11] used $PSScriptRoot instead --- Examples/ConditionalFormatting/GetConditionalFormatting.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 b/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 index a9bc3a9..e123fc8 100644 --- a/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 +++ b/Examples/ConditionalFormatting/GetConditionalFormatting.ps1 @@ -17,5 +17,5 @@ function Get-ConditionalFormatting { } } -$xlSourcefile = "$env:TEMP.\GetConditionalFormatting.xlsx" +$xlSourcefile = "$PSScriptRoot\GetConditionalFormatting.xlsx" Get-ConditionalFormatting -xlSourcefile $xlSourcefile \ No newline at end of file From 81e60be51d04695e684c0d6ff4456b6c3d735fa0 Mon Sep 17 00:00:00 2001 From: chadmando Date: Wed, 13 Jul 2022 15:36:17 -0500 Subject: [PATCH 11/11] Fix typo in help Open-ExcelPackage Example #2 Line#48 remove 'and' --- mdHelp/en/open-excelpackage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdHelp/en/open-excelpackage.md b/mdHelp/en/open-excelpackage.md index be6dc95..ce22d2b 100644 --- a/mdHelp/en/open-excelpackage.md +++ b/mdHelp/en/open-excelpackage.md @@ -45,7 +45,7 @@ PS\> Set-ExcelRange -Range $sheet1.Cells ["E1:S1048576" ], $sheet1.Cells ["V1:V1 PS\> 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 saved and loaded into Excel. ## PARAMETERS