Class: OpenXml::Xlsx::Parts::SharedStrings
- Inherits:
-
Part
- Object
- Part
- OpenXml::Xlsx::Parts::SharedStrings
- Defined in:
- lib/openxml/xlsx/parts/shared_strings.rb
Instance Attribute Summary collapse
-
#strings ⇒ Object
readonly
Returns the value of attribute strings.
Instance Method Summary collapse
-
#initialize ⇒ SharedStrings
constructor
A new instance of SharedStrings.
- #reference_of(string) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize ⇒ SharedStrings
Returns a new instance of SharedStrings.
7 8 9 |
# File 'lib/openxml/xlsx/parts/shared_strings.rb', line 7 def initialize @strings = Hash.new { |hash, key| hash[key] = hash.length } end |
Instance Attribute Details
#strings ⇒ Object (readonly)
Returns the value of attribute strings.
5 6 7 |
# File 'lib/openxml/xlsx/parts/shared_strings.rb', line 5 def strings @strings end |
Instance Method Details
#reference_of(string) ⇒ Object
11 12 13 |
# File 'lib/openxml/xlsx/parts/shared_strings.rb', line 11 def reference_of(string) strings[string] end |
#to_xml ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/openxml/xlsx/parts/shared_strings.rb', line 15 def to_xml build_standalone_xml do |xml| xml.sst(xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", uniqueCount: strings.length) do strings.each do |string, i| xml.si { xml.t(string) } end end end end |