Skip to content

Instantly share code, notes, and snippets.

@arjan
Created July 11, 2013 12:08
Show Gist options
  • Save arjan/5974897 to your computer and use it in GitHub Desktop.
Save arjan/5974897 to your computer and use it in GitHub Desktop.
Given 0-based column number return the Excel column name.
%% Given 0-based column number return the Excel column name as list.
column(N) ->
column(N, []).
column(N, Acc) when N < 26 ->
[(N)+$A | Acc];
column(N, Acc) ->
column(N div 26-1, [(N rem 26)+$A|Acc]).
@arjan
Copy link
Author

arjan commented Jul 11, 2013

(zotonic001@x1)99> xlsx_sheet:column(0).    
"A"
(zotonic001@x1)100> xlsx_sheet:column(1).
"B"
(zotonic001@x1)101> xlsx_sheet:column(25).
"Z"
(zotonic001@x1)102> xlsx_sheet:column(26).
"AA"
(zotonic001@x1)103> xlsx_sheet:column(51).
"AZ"
(zotonic001@x1)104> xlsx_sheet:column(52).
"BA"
(zotonic001@x1)105> xlsx_sheet:column(53).
"BB"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment