excelColumnNumtoColumnName(columnName)
Last updated May 03, 2010
Version: 1 | Requires: CF5 | Library: UtilityLib
Description:
Converts a numeric column position (i.e. 127) to its Excel Column Name (DW). Assumes column numbers are 1-based (1=A,2=B,...)
Return Values:
Returns a string.
Example:
column 1 is #ExcelColumnNumtoColumnName(1)#<br/>
column 18 is #ExcelColumnNumtoColumnName(18)#<br/>
column 100 is #ExcelColumnNumtoColumnName(100)#<br/>
column 653 is #ExcelColumnNumtoColumnName(653)#
Parameters:
Name | Description | Required |
---|---|---|
columnName | Numeric column number. | Yes |
Full UDF Source:
/**
* Converts a numeric column position to its Excel Column Name
*
* @param columnName Numeric column number. (Required)
* @return Returns a string.
* @author Adam Tuttle (adam@fusiongrokker.com)
* @version 1, May 3, 2010
*/
function excelColumnNumtoColumnName(columnNumber){
var dividend = fix(arguments.columnNumber); //make sure input is an integer
var columnName = '';
var modulo = 0;
//if dividend <= 0, an empty string will be returned
while (dividend gt 0){
modulo = (dividend - 1) mod 26;
columnName = "#chr(65 + modulo)##columnName#";
dividend = fix((dividend - modulo) / 26);
}
return columnName;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016