How to generate Excel column symbols in Ruby
('A'..'Z').to_a.unshift(nil).product(('A'..'Z').to_a).map { |arr| arr.compact.join }
If you would like to keep it as a CONSTANT it should be frozen
EXCEL_COLUMNS =
('A'..'Z').to_a.unshift(nil).product(('A'..'Z').to_a)
.map { |arr| arr.compact.join }
.map(&:freeze).freeze
Comments
Empty! You must sign in to add comments.