mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Expand Number format now sets regional layout for currency
This commit is contained in:
@@ -266,10 +266,37 @@ if (Get-Command -ErrorAction SilentlyContinue -name Register-ArgumentCompleter)
|
||||
Function Expand-NumberFormat {
|
||||
param ($NumberFormat)
|
||||
switch ($NumberFormat) {
|
||||
"Currency" {return [cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol + "#,##0.00"}
|
||||
"Currency" {
|
||||
#https://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencynegativepattern(v=vs.110).aspx
|
||||
$sign = [cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol
|
||||
switch ([cultureinfo]::CurrentCulture.NumberFormat.CurrencyPositivePattern) {
|
||||
0 {$pos = "$Sign#,##0.00" ; break }
|
||||
1 {$pos = "#,##0.00$Sign" ; break }
|
||||
2 {$pos = "$Sign #,##0.00" ; break }
|
||||
3 {$pos = "#,##0.00 $Sign" ; break }
|
||||
}
|
||||
switch ([cultureinfo]::CurrentCulture.NumberFormat.CurrencyPositivePattern) {
|
||||
0 {return "$pos;($Sign#,##0.00)" }
|
||||
1 {return "$pos;-$Sign#,##0.00" }
|
||||
2 {return "$pos;$Sign-#,##0.00" }
|
||||
3 {return "$pos;$Sign#,##0.00-" }
|
||||
4 {return "$pos;(#,##0.00$Sign)" }
|
||||
5 {return "$pos;-#,##0.00$Sign" }
|
||||
6 {return "$pos;#,##0.00-$Sign" }
|
||||
7 {return "$pos;#,##0.00$Sign-" }
|
||||
8 {return "$pos;-#,##0.00 $Sign" }
|
||||
9 {return "$pos;-$Sign #,##0.00" }
|
||||
10 {return "$pos;#,##0.00 $Sign-" }
|
||||
11 {return "$pos;$Sign #,##0.00-" }
|
||||
12 {return "$pos;$Sign -#,##0.00" }
|
||||
13 {return "$pos;#,##0.00- $Sign" }
|
||||
14 {return "$pos;($Sign #,##0.00)" }
|
||||
15 {return "$pos;(#,##0.00 $Sign)" }
|
||||
}
|
||||
}
|
||||
"Number" {return "0.00" } # format id 2
|
||||
"Percentage" {return "0.00%" } # format id 10
|
||||
"Scientific" {return "0.00E+00" } # format id 11
|
||||
"Scientific" {return "0.00E+00" } # format id 11
|
||||
"Fraction" {return "# ?/?" } # format id 12
|
||||
"Short Date" {return "mm-dd-yy" } # format id 14 localized on load by Excel.
|
||||
"Short Time" {return "h:mm" } # format id 20 localized on load by Excel.
|
||||
@@ -278,4 +305,4 @@ Function Expand-NumberFormat {
|
||||
"Text" {return "@" } # format ID 49
|
||||
Default {return $NumberFormat}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user