lib/writeexcel/helper.rb in writeexcel-0.4.1 vs lib/writeexcel/helper.rb in writeexcel-0.4.2

- old
+ new

@@ -38,5 +38,27 @@ def ascii_to_16be(ascii) ascii.unpack("C*").pack("n*") ascii.force_encoding('UTF-16BE') end private :ascii_to_16be + + def store_simple(record, length, *args) + header = [record, length].pack('vv') + data = args.collect { |arg| [arg].pack('v') }.join('') + + append(header, data) + end + private :store_simple + + # Convert base26 column string to a number. + # All your Base are belong to us. + def chars_to_col(chars) + expn = 0 + col = 0 + while (!chars.empty?) + char = chars.pop # LS char first + col += (char.ord - "A".ord + 1) * (26 ** expn) + expn += 1 + end + col + end + private :chars_to_col