Method: RubyXL::Reference.ref2ind

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

.ref2ind(str) ⇒ Object

Converts Excel-style cell reference to row and col zero-based indices.

[View source]

103
104
105
106
107
# File 'lib/rubyXL/objects/reference.rb', line 103

def self.ref2ind(str)
  return [ -1, -1 ] unless str =~ /\A([A-Z]+)(\d+)\Z/
  [ Regexp.last_match(2).to_i - 1,
    Regexp.last_match(1).each_byte.inject(0) { |col, chr| (col * 26) + (chr - 64) } - 1 ]
end