mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added Number Formatting
This commit is contained in:
13
Examples/NumberFormat/ColorizeNumbers.ps1
Normal file
13
Examples/NumberFormat/ColorizeNumbers.ps1
Normal file
@@ -0,0 +1,13 @@
|
||||
$file = "disks.xlsx"
|
||||
|
||||
rm $file -ErrorAction Ignore
|
||||
|
||||
$data = $(
|
||||
New-PSItem 100 -100
|
||||
New-PSItem 1 -1
|
||||
New-PSItem 1.2 -1.1
|
||||
New-PSItem -3.2 -4.1
|
||||
New-PSItem -5.2 6.1
|
||||
)
|
||||
|
||||
$data | Export-Excel -Path $file -Show -AutoSize -NumberFormat "[Blue]+0.#0;[Red]-0.#0"
|
||||
15
Examples/NumberFormat/CurrencyFormat.ps1
Normal file
15
Examples/NumberFormat/CurrencyFormat.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
$file = "disks.xlsx"
|
||||
|
||||
rm $file -ErrorAction Ignore
|
||||
|
||||
$data = $(
|
||||
New-PSItem 100 -100
|
||||
New-PSItem 1 -1
|
||||
New-PSItem 1.2 -1.1
|
||||
New-PSItem -3.2 -4.1
|
||||
New-PSItem -5.2 6.1
|
||||
New-PSItem 1000 -2000
|
||||
)
|
||||
|
||||
$data | Export-Excel -Path $file -Show -AutoSize -NumberFormat '[Blue]$#,##0.00;[Red]-$#,##0.00'
|
||||
|
||||
14
Examples/NumberFormat/PercentagFormat.ps1
Normal file
14
Examples/NumberFormat/PercentagFormat.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
$file = "disks.xlsx"
|
||||
|
||||
rm $file -ErrorAction Ignore
|
||||
|
||||
$data = $(
|
||||
New-PSItem 1
|
||||
New-PSItem .5
|
||||
New-PSItem .3
|
||||
New-PSItem .41
|
||||
New-PSItem .2
|
||||
New-PSItem -.12
|
||||
)
|
||||
|
||||
$data | Export-Excel -Path $file -Show -AutoSize -NumberFormat "0.0%;[Red]-0.0%"
|
||||
11
Examples/NumberFormat/PosNegNumbers.ps1
Normal file
11
Examples/NumberFormat/PosNegNumbers.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
$file = "disks.xlsx"
|
||||
|
||||
rm $file -ErrorAction Ignore
|
||||
|
||||
$data = $(
|
||||
New-PSItem 100 -100
|
||||
New-PSItem 1 -1
|
||||
New-PSItem 1.2 -1.1
|
||||
)
|
||||
|
||||
$data | Export-Excel -Path $file -Show -AutoSize -NumberFormat "0.#0;-0.#0"
|
||||
7
Examples/NumberFormat/Win32LogicalDisk.ps1
Normal file
7
Examples/NumberFormat/Win32LogicalDisk.ps1
Normal file
@@ -0,0 +1,7 @@
|
||||
$file = "disks.xlsx"
|
||||
|
||||
rm $file -ErrorAction Ignore
|
||||
|
||||
Get-CimInstance win32_logicaldisk -filter "drivetype=3" |
|
||||
Select DeviceID,Volumename,Size,Freespace |
|
||||
Export-Excel -Path $file -Show -AutoSize -NumberFormat "0"
|
||||
7
Examples/NumberFormat/Win32LogicalDiskFormatted.ps1
Normal file
7
Examples/NumberFormat/Win32LogicalDiskFormatted.ps1
Normal file
@@ -0,0 +1,7 @@
|
||||
$file = "disks.xlsx"
|
||||
|
||||
rm $file -ErrorAction Ignore
|
||||
|
||||
Get-CimInstance win32_logicaldisk -filter "drivetype=3" |
|
||||
Select DeviceID,Volumename,Size,Freespace |
|
||||
Export-Excel -Path $file -Show -AutoSize
|
||||
Reference in New Issue
Block a user