From 669570ed0be33441da3a128e8eb37aece90e4bdd Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 12 Feb 2012 13:01:27 +0900 Subject: patching unbalanced ends --- lib/axlsx/workbook/shared_strings_table.rb | 37 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/axlsx/workbook/shared_strings_table.rb b/lib/axlsx/workbook/shared_strings_table.rb index afd8498c..f8c2361e 100644 --- a/lib/axlsx/workbook/shared_strings_table.rb +++ b/lib/axlsx/workbook/shared_strings_table.rb @@ -32,7 +32,7 @@ module Axlsx cells = cells.flatten.reject { |c| c.type != :string } @count = cells.size @unique_cells = [] - resolve cells + resolve(cells) end @@ -48,25 +48,24 @@ module Axlsx end builder.to_xml(:save_with => 0) end - end - - private - # Interate over all of the cells in the array. - # if our unique cells array does not contain a sharable cell, - # add the cell to our unique cells array and set the ssti attribute on the index of this cell in the shared strings table - # if a sharable cell already exists in our unique_cells array, set the ssti attribute of the cell and move on. - # @return [Array] unique cells - def resolve(cells) - cells.each do |cell| - index = @unique_cells.index { |item| item.shareable(cell) } - if index == nil - cell.send :ssti=, @unique_cells.size - @unique_cells << cell - else - cell.send :ssti=, index + private + + # Interate over all of the cells in the array. + # if our unique cells array does not contain a sharable cell, + # add the cell to our unique cells array and set the ssti attribute on the index of this cell in the shared strings table + # if a sharable cell already exists in our unique_cells array, set the ssti attribute of the cell and move on. + # @return [Array] unique cells + def resolve(cells) + cells.each do |cell| + index = @unique_cells.index { |item| item.shareable(cell) } + if index == nil + cell.send :ssti=, @unique_cells.size + @unique_cells << cell + else + cell.send :ssti=, index + end end - end + end end - end -- cgit v1.2.3