mirror of
https://github.com/dfinke/ImportExcel.git
synced 2026-01-06 18:43:25 +00:00
Move help from Comment-based to md. Relocate functions (sans help)
This commit is contained in:
27
ExportedCommands/Get-ExcelColumnName.ps1
Normal file
27
ExportedCommands/Get-ExcelColumnName.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
function Get-ExcelColumnName {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$true)]
|
||||
$columnNumber=1
|
||||
)
|
||||
|
||||
Process {
|
||||
$dividend = $columnNumber
|
||||
$columnName = New-Object System.Collections.ArrayList($null)
|
||||
|
||||
while($dividend -gt 0) {
|
||||
$modulo = ($dividend - 1) % 26
|
||||
if ($columnName.length -eq 0) {
|
||||
[char](65 + $modulo)
|
||||
} else {
|
||||
$columnName.insert(0,[char](65 + $modulo))
|
||||
}
|
||||
$dividend = [int](($dividend -$modulo)/26)
|
||||
}
|
||||
|
||||
[PSCustomObject] @{
|
||||
ColumnNumber = $columnNumber
|
||||
ColumnName = $columnName -join ''
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user