lib/axlsx.rb in axlsx-1.0.10 vs lib/axlsx.rb in axlsx-1.0.11

- old
+ new

@@ -1,12 +1,15 @@ - Encoding::default_internal = 'UTF-8' unless RUBY_VERSION < '1.9' Encoding::default_external = 'UTF-8' unless RUBY_VERSION < '1.9' require 'axlsx/util/simple_typed_list.rb' require 'axlsx/util/constants.rb' require 'axlsx/util/validators.rb' + +# to be included with parsable intitites. +#require 'axlsx/util/parser.rb' + require 'axlsx/stylesheet/styles.rb' require 'axlsx/doc_props/app.rb' require 'axlsx/doc_props/core.rb' require 'axlsx/content_type/content_type.rb' @@ -35,7 +38,17 @@ return "" unless items.first.is_a? Cell ref = "#{items.first.row.worksheet.name}!" + "#{items.first.r_abs}" ref += ":#{items.last.r_abs}" if items.size > 1 ref + end + + def self.name_to_indices(name) + raise ArgumentError, 'invalid cell name' unless name.size > 1 + v = name[/[A-Z]+/].reverse.chars.reduce({:base=>1, :i=>0}) do |v, c| + v[:i] += ((c.bytes.first - 65) + v[:base]); v[:base] *= 26; v + end + + [v[:i]-1, ((name[/[1-9]+/]).to_i)-1] + end end