Method: RubyXL::Reference.ind2ref

Defined in:
lib/rubyXL/objects/reference.rb

.ind2ref(row = 0, col = 0) ⇒ Object

Converts row and col zero-based indices to Excel-style cell reference <0> A…Z, AA…AZ, BA… …ZZ, AAA… …AZZ, BAA… …XFD <16383>

[View source]

89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rubyXL/objects/reference.rb', line 89

def self.ind2ref(row = 0, col = 0)
  str = ''

  loop do
    x = col % 26
    str = ('A'.ord + x).chr + str
    col = (col / 26).floor - 1
    break if col < 0
  end

  str += (row + 1).to_s
end