mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Add Sheet visibility property
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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" {
|
||||
@@ -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'
|
||||
@@ -26,6 +25,7 @@ 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'
|
||||
@@ -33,11 +33,20 @@ Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {
|
||||
|
||||
$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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
__tests__/ImportExcelTests/SheetVisibleTesting.xlsx
Normal file
BIN
__tests__/ImportExcelTests/SheetVisibleTesting.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user