Improved behavior of -NumberFormat in Export-Excel

This commit is contained in:
jhoneill
2018-08-15 22:52:22 +01:00
parent ce3fd2021f
commit bc65699068
3 changed files with 31 additions and 5 deletions

View File

@@ -143,6 +143,27 @@ Describe ExportExcel {
}
}
Context " # Number format parameter" {
BeforeAll {
$path = "$env:temp\test.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
1..10 | Export-Excel -Path $path -Numberformat 'Number'
1..10 | Export-Excel -Path $path -Numberformat 'Percentage' -Append
21..30 | Export-Excel -Path $path -Numberformat 'Currency' -StartColumn 3
$excel = Open-ExcelPackage -Path $path
$ws = $excel.Workbook.Worksheets[1]
}
it "Set the worksheet default number format correctly " {
$ws.Cells.Style.Numberformat.Format | Should be "0.00"
}
it "Set number formats on specific blocks of cells w " {
$ws.Cells["A2" ].Style.Numberformat.Format | Should be "0.00"
$ws.Cells["c19"].Style.Numberformat.Format | Should be "0.00"
$ws.Cells["A19"].Style.Numberformat.Format | Should be "0.00%"
$ws.Cells["C6" ].Style.Numberformat.Format | Should be (Expand-NumberFormat "currency")
}
}
Context "#Examples 3 & 4 # Setting cells for different data types Also added test for URI type" {
if ((Get-Culture).NumberFormat.CurrencySymbol -eq "£") {$OtherCurrencySymbol = "$"}