diff options
| author | Jean Jacques Warmerdam <[email protected]> | 2013-07-24 12:32:54 +0200 |
|---|---|---|
| committer | Jean Jacques Warmerdam <[email protected]> | 2013-07-24 12:32:54 +0200 |
| commit | 88ee2b1ca8aee6bd14c838f247654f43c073fd2e (patch) | |
| tree | f5414ad991971477ac7b0286ebb3067dc5ca2cf7 /lib/axlsx/workbook/shared_strings_table.rb | |
| parent | 35d3cc8b21bce0c4ce7b9ec4e29d52df4b5f9cc4 (diff) | |
| parent | 7fb6629b6f1e56b3e012613ec8cfcda8628c0ca5 (diff) | |
| download | caxlsx-88ee2b1ca8aee6bd14c838f247654f43c073fd2e.tar.gz caxlsx-88ee2b1ca8aee6bd14c838f247654f43c073fd2e.zip | |
Merge branch 'master' of https://github.com/randym/axlsx
Diffstat (limited to 'lib/axlsx/workbook/shared_strings_table.rb')
| -rw-r--r-- | lib/axlsx/workbook/shared_strings_table.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/axlsx/workbook/shared_strings_table.rb b/lib/axlsx/workbook/shared_strings_table.rb index 43e8a1a8..7c08205e 100644 --- a/lib/axlsx/workbook/shared_strings_table.rb +++ b/lib/axlsx/workbook/shared_strings_table.rb @@ -26,10 +26,16 @@ module Axlsx # @see Cell#sharable attr_reader :unique_cells + # The xml:space attribute + # @see Workbook#xml_space + attr_reader :xml_space + # Creates a new Shared Strings Table agains an array of cells # @param [Array] cells This is an array of all of the cells in the workbook - def initialize(cells) + # @param [Symbol] xml_space The xml:space behavior for the shared string table. + def initialize(cells, xml_space=:preserve) @index = 0 + @xml_space = xml_space @unique_cells = {} @shared_xml_string = "" shareable_cells = cells.flatten.select{ |cell| cell.plain_string? } @@ -40,8 +46,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string - '<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '" count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '">' << @shared_xml_string << '</sst>' + def to_xml_string(str='') + str << '<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '"' + str << ' count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '"' + str << ' xml:space="' << xml_space.to_s << '">' << @shared_xml_string << '</sst>' end private |
