Skip to content

Instantly share code, notes, and snippets.

@amalc
Created July 9, 2009 16:38
Show Gist options
  • Save amalc/143790 to your computer and use it in GitHub Desktop.
Save amalc/143790 to your computer and use it in GitHub Desktop.
Converting R1C1 style references for spreadsheets to AA1 style
# 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