Skip to content

Commit

Permalink
Add Sheet visibility property
Browse files Browse the repository at this point in the history
  • Loading branch information
dfinke committed Oct 15, 2022
1 parent 559bfa2 commit 201b9cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Public/Get-ExcelFileSummary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function Get-ExcelFileSummary {
[PSCustomObject][Ordered]@{
ExcelFile = Split-Path -Leaf $Path
WorksheetName = $workSheet.Name
Visible = $workSheet.Hidden -eq 'Visible'
Rows = $workSheet.Dimension.Rows
Columns = $workSheet.Dimension.Columns
Address = $workSheet.Dimension.Address
Expand Down
15 changes: 12 additions & 3 deletions __tests__/Get-ExcelFileSummary.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '', Justification = 'Only executes on versions without the automatic variable')]
param()

if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Import-Module $PSScriptRoot\..\ImportExcel.psd1
}
Import-Module $PSScriptRoot\..\ImportExcel.psd1 -Force

Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {
Context "Test Get-ExcelFileSummary" {
Expand All @@ -14,6 +12,7 @@ Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {

$actual.ExcelFile | Should -BeExactly 'TestData1.xlsx'
$actual.WorksheetName | Should -BeExactly 'Sheet1'
$actual.Visible | Should -BeTrue
$actual.Rows | Should -Be 3
$actual.Columns | Should -Be 2
$actual.Address | Should -BeExactly 'A1:B3'
Expand All @@ -26,18 +25,28 @@ Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {

$actual[0].ExcelFile | Should -BeExactly 'MultipleSheets.xlsx'
$actual[0].WorksheetName | Should -BeExactly 'Sheet1'
$actual[0].Visible | Should -BeTrue
$actual[0].Rows | Should -Be 1
$actual[0].Columns | Should -Be 4
$actual[0].Address | Should -BeExactly 'A1:D1'
$actual[0].Path | Should -Not -BeNullOrEmpty

$actual[1].ExcelFile | Should -BeExactly 'MultipleSheets.xlsx'
$actual[1].WorksheetName | Should -BeExactly 'Sheet2'
$actual[1].Visible | Should -BeTrue
$actual[1].Rows | Should -Be 2
$actual[1].Columns | Should -Be 2
$actual[1].Address | Should -BeExactly 'A1:B2'
$actual[1].Path | Should -Not -BeNullOrEmpty
}

It "Tests if sheet is hidden or not" {
$actual = Get-ExcelFileSummary "$PSScriptRoot\ImportExcelTests\SheetVisibleTesting.xlsx"

$actual[0].Visible | Should -BeTrue
$actual[1].Visible | Should -BeFalse
$actual[2].Visible | Should -BeTrue
$actual[3].Visible | Should -BeFalse
}
}
}
Binary file not shown.

0 comments on commit 201b9cd

Please sign in to comment.