Altova Mailing List Archives

Re: Translate number to an alphabetic code

From: Bjoern Hoehrmann <bjoern@---------.-->
Date: 2/19/2007 1:09:00 PM

* shurik wrote in microsoft.public.xsl:
>I need to translate numbers to alphabetic codes. I am generating an EXCEL 
>workbook, and I need to generate excel cell references from cell numbers.
>For example 1 translates to A 
>2 -> B
>26 -> Z
>27 -> AA
>28 -> AB
>For now I implemented the translation using helper variable containing array 
>of leters:
><xsl:variable name="lettersTmp">
><xsl:variable name="letters" selec="msxsl:node-set($lettersTmp)/r"/>
>Translation is performed as follows:
><xsl:value-of select="$letters[position() = $cellIndex]"/>
>I am using XsltCompiledTransform engine (XSLT 1.0). 
>Just curious, is there more elegant\efficient solution?

An extension function (that you write in some programming language and
register with the XSLT processor) would be simpler, and you could also
make a recursive template that uses a simple table for a single char and
concats them together. Also note that instead of using a variable, you
can use something like

  <xsl:transform ...>

which is then referenced using


which makes using msxsl:node-set unncessary.
Björn Höhrmann · mailto:bjoern@h... ·
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · 


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.