diff options
| author | Randy Morgan <[email protected]> | 2012-03-28 00:52:30 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-03-28 00:52:30 +0900 |
| commit | ec9d3b896a2b07cdcb8198c2227df8dac3b83cdb (patch) | |
| tree | bb0da233e87c50d6560fb236543e6fa2a12fe642 /lib/axlsx/workbook/shared_strings_table.rb | |
| parent | be2d7bee9b9236fff4a378db8770c3ae793e8422 (diff) | |
| download | caxlsx-ec9d3b896a2b07cdcb8198c2227df8dac3b83cdb.tar.gz caxlsx-ec9d3b896a2b07cdcb8198c2227df8dac3b83cdb.zip | |
Still not fast enough?
```
user system total real
axlsx_noautowidth 0.760000 0.020000 0.780000 ( 0.885482)
axlsx 3.560000 0.130000 3.690000 ( 4.158594)
axlsx_shared 11.610000 0.180000 11.790000 ( 13.208945)
axlsx_stream 3.450000 0.120000 3.570000 ( 3.920745)
csv 0.240000 0.010000 0.250000 ( 0.269822)
Diffstat (limited to 'lib/axlsx/workbook/shared_strings_table.rb')
| -rw-r--r-- | lib/axlsx/workbook/shared_strings_table.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/axlsx/workbook/shared_strings_table.rb b/lib/axlsx/workbook/shared_strings_table.rb index 5ebfd87f..0bdd7936 100644 --- a/lib/axlsx/workbook/shared_strings_table.rb +++ b/lib/axlsx/workbook/shared_strings_table.rb @@ -32,11 +32,12 @@ module Axlsx cells = cells.flatten.reject { |c| c.type != :string || c.value.start_with?('=') } @count = cells.size @unique_cells = [] + @shared_xml_string = "" resolve(cells) end def to_xml_string - str = "<sst xmlns=\"%s\" count='%s' uniqueCount='%s'>%s</sst>" % [XML_NS, count, unique_count, @unique_cells.map {|cell| cell[:data]}.join] + '<sst xmlns="' << XML_NS << '" count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '">' << @shared_xml_string << '</sst>' end # Generate the xml document for the Shared Strings Table @@ -64,11 +65,12 @@ module Axlsx cells.each do |cell| cell_hash = cell.shareable_hash index = @unique_cells.index do |item| - item[:hash] == cell_hash + item == cell_hash end if index == nil cell.send :ssti=, @unique_cells.size - @unique_cells << {:hash => cell_hash, :data => '<si>'<< cell.run_xml_string << '</si>'} + @shared_xml_string << '<si>' << cell.run_xml_string << '</si>' + @unique_cells << cell_hash else cell.send :ssti=, index end |
