mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Tider errors for file open on import; password tests
This commit is contained in:
24
__tests__/PasswordProtection.ps1
Normal file
24
__tests__/PasswordProtection.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
Describe "Password Support" {
|
||||
Context "Password protected sheet" {
|
||||
BeforeAll {
|
||||
$password = "YouMustRememberThis"
|
||||
$path = "$env:TEMP\Test.xlsx"
|
||||
Remove-Item $path -ErrorAction SilentlyContinue
|
||||
Get-Service | Select-Object -First 10 | Export-excel -password $password -Path $Path -DisplayPropertySet
|
||||
}
|
||||
it "Threw an error when the password was omitted " {
|
||||
{Open-ExcelPackage -Path $path } | should throw
|
||||
}
|
||||
it "Was able to append when the password was included " {
|
||||
{Get-Service | Select-Object -First 10 |
|
||||
Export-excel -password $password -Path $Path -Append } | should not throw
|
||||
}
|
||||
it "Kept the password on the file when it was saved " {
|
||||
{Import-Excel $Path } | should throw
|
||||
}
|
||||
it "Could read the file when the password was included " {
|
||||
(import-excel $path -Password $password).count | should be 20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ Describe "Number format expansion and setting" {
|
||||
Remove-Item -Path $path -ErrorAction SilentlyContinue
|
||||
$n = [datetime]::Now.ToOADate()
|
||||
|
||||
$excel = 1..32 | ForEach-Object {$n} | Export-Excel -Path $path -PassThru
|
||||
$excel = 1..32 | ForEach-Object {$n} | Export-Excel -Path $path -show -WorksheetName s2 -PassThru
|
||||
$ws = $excel.Workbook.Worksheets[1]
|
||||
Set-Format -WorkSheet $ws -Range "A1" -numberFormat 'General'
|
||||
Set-Format -WorkSheet $ws -Range "A2" -numberFormat 'Number'
|
||||
|
||||
Reference in New Issue
Block a user