Created
July 9, 2009 16:38
-
-
Save amalc/143790 to your computer and use it in GitHub Desktop.
Converting R1C1 style references for spreadsheets to AA1 style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Converts row / column references to letter based column row references | |
# for spreadsheet addressing. Assumes 0 base. | |
def convert_row_column_to_cell_reference(r, c, ref) | |
throw :column_reference_too_large if c > 255 | |
if c / 26 == 0 | |
ref << (c%26+65).chr+(r+1).to_s | |
else | |
ref << (c/26+64).chr | |
convert_row_column_to_cell_reference(r, c%26, ref) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment