-
Notifications
You must be signed in to change notification settings - Fork 421
Closed
Labels
Description
Consider the following code:
if (!($TempFolder = $env:TEMP + '\TestFolder')) {
New-Item -Path $TempFolder -ItemType Directory
}
$F = New-Object System.IO.FileStream ($TempFolder + '\File1.txt'), Create, ReadWrite
$F.SetLength(763905024)
$F.Close()
$F = New-Object System.IO.FileStream ($TempFolder + '\File2.txt'), Create, ReadWrite
$F.SetLength(1631405056)
$F.Close()
$F = New-Object System.IO.FileStream ($TempFolder + '\File3.txt'), Create, ReadWrite
$F.SetLength(271360)
$F.Close()
$F = New-Object System.IO.FileStream ($TempFolder + '\File4.txt'), Create, ReadWrite
$F.SetLength(417006592)
$F.Close()
$ExcelFile = $env:TEMP + '\Excel.xlsx'
if (Test-Path -Path $ExcelFile) {
Remove-Item -Path $ExcelFile -Force
}
Get-ChildItem -Path $TempFolder |
Select-Object Name, Length, @{Name="Mb";Expression={'{0:N2}' -f ($_.Length/1Mb)}} |
Export-Excel $ExcelFile -Show
As you can see, the values behind the comma are discarded.
Example: 0,26 becomes 26 in the Excel file.
Also, some cells are stored as text rather then number. see C3.
