module Tolq::Parsers::XLSX::ColumnHelper
Public Class Methods
char_to_column(char)
click to toggle source
Converts char to column, zero indexed
# File lib/xlsx/column_helper.rb, line 18 def self.char_to_column(char) char .split('') .reverse .map.with_index { |c,idx| (c.ord - 64) * (26**idx)} .inject(&:+) - 1 end
column_to_char(idx)
click to toggle source
Converts column to char, zero indexed
# File lib/xlsx/column_helper.rb, line 4 def self.column_to_char(idx) dividend = idx + 1 column_name = "" while dividend > 0 modulo = (dividend - 1) % 26 column_name = (65 + modulo).chr + column_name dividend = (dividend - modulo) / 26 end column_name end
from_char_notation(key)
click to toggle source
# File lib/xlsx/column_helper.rb, line 26 def self.from_char_notation(key) char, row = key.scan(/([A-Z]+)(\d+)/).first return row.to_i - 1, ColumnHelper.char_to_column(char) end