lib/axlsx.rb in axlsx-1.3.1 vs lib/axlsx.rb in axlsx-1.3.2

- old
+ new

@@ -3,11 +3,13 @@ require 'axlsx/version.rb' require 'axlsx/util/simple_typed_list.rb' require 'axlsx/util/constants.rb' require 'axlsx/util/validators.rb' - +require 'axlsx/util/accessors.rb' +require 'axlsx/util/serialized_attributes' +require 'axlsx/util/options_parser' # to be included with parsable intitites. #require 'axlsx/util/parser.rb' require 'axlsx/stylesheet/styles.rb' @@ -46,13 +48,18 @@ module Axlsx # determines the cell range for the items provided def self.cell_range(cells, absolute=true) return "" unless cells.first.is_a? Cell - sort_cells(cells) + cells = sort_cells(cells) reference = "#{cells.first.reference(absolute)}:#{cells.last.reference(absolute)}" - absolute ? "'#{cells.first.row.worksheet.name}'!#{reference}" : reference + if absolute + escaped_name = cells.first.row.worksheet.name.gsub "'", "''" + "'#{escaped_name}'!#{reference}" + else + reference + end end # sorts the array of cells provided to start from the minimum x,y to # the maximum x.y# # @param [Array] cells @@ -64,10 +71,10 @@ #global reference html entity encoding # @return [HtmlEntities] def self.coder @@coder ||= ::HTMLEntities.new end - + # returns the x, y position of a cell def self.name_to_indices(name) raise ArgumentError, 'invalid cell name' unless name.size > 1 # capitalization?!? v = name[/[A-Z]+/].reverse.chars.reduce({:base=>1, :i=>0}) do |val, c|