Method: Axlsx.col_ref

Defined in:
lib/axlsx.rb

.col_ref(index) ⇒ String

Note:

This follows the standard spreadsheet convention of naming columns A to Z, followed by AA to AZ etc.

converts the column index into alphabetical values.

Returns:

  • (String)


90
91
92
93
94
95
96
97
98
# File 'lib/axlsx.rb', line 90

def self.col_ref(index)
  chars = []
  while index >= 26 do
    chars << ((index % 26) + 65).chr
    index = (index / 26).to_i - 1
  end
  chars << (index + 65).chr
  chars.reverse.join
end