Calculate Excel Column Name By Number Using Powershell.
function Get-ExcelCol{
param( [int]$Number)
end{
[string]$res=""
while($Number -gt 0 ) {
$res= [System.Convert]::ToChar((($Number-1) % 26) +65 ) +$res
$Number=($Number-(($Number-1) % 26))/26
}
$res
}
}
Result:
PS C:\> Get-ExcelCol 26
Z
PS C:\> Get-ExcelCol 27
AA
PS C:\> Get-ExcelCol 52
AZ
PS C:\> Get-ExcelCol 53
BA
Babak
#Powershell #cmdlet #function #excel #column #Get-ExcelCol
1/29/2014 6:31:25 AM