Class: OpenXml::Xlsx::Package

Inherits:
Package
  • Object
show all
Defined in:
lib/openxml/xlsx/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePackage

Returns a new instance of Package.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/openxml/xlsx/package.rb', line 20

def initialize
  super
  rels.add_relationship REL_DOCUMENT, "xl/workbook.xml"

  @xl_rels = OpenXml::Parts::Rels.new([
    { "Type" => REL_SHARED_STRINGS, "Target" => "sharedStrings.xml" },
    { "Type" => REL_STYLES, "Target" => "styles.xml" }
  ])
  @shared_strings = Xlsx::Parts::SharedStrings.new
  @stylesheet = Xlsx::Parts::Stylesheet.new
  @workbook = Xlsx::Parts::Workbook.new(self)

  # docProps/app.xml
  # docProps/core.xml
  add_part "xl/_rels/workbook.xml.rels", xl_rels
  # xl/calcChain.xml
  add_part "xl/sharedStrings.xml", shared_strings
  add_part "xl/styles.xml", stylesheet
  # xl/theme/theme1.xml
  add_part "xl/workbook.xml", workbook
end

Instance Attribute Details

#shared_stringsObject (readonly)

Returns the value of attribute shared_strings.



6
7
8
# File 'lib/openxml/xlsx/package.rb', line 6

def shared_strings
  @shared_strings
end

#stylesheetObject (readonly)

Returns the value of attribute stylesheet.



6
7
8
# File 'lib/openxml/xlsx/package.rb', line 6

def stylesheet
  @stylesheet
end

#workbookObject (readonly)

Returns the value of attribute workbook.



6
7
8
# File 'lib/openxml/xlsx/package.rb', line 6

def workbook
  @workbook
end

#xl_relsObject (readonly)

Returns the value of attribute xl_rels.



6
7
8
# File 'lib/openxml/xlsx/package.rb', line 6

def xl_rels
  @xl_rels
end

Instance Method Details

#string_ref(string) ⇒ Object



42
43
44
# File 'lib/openxml/xlsx/package.rb', line 42

def string_ref(string)
  shared_strings.reference_of(string)
end

#style_ref(style) ⇒ Object



46
47
48
# File 'lib/openxml/xlsx/package.rb', line 46

def style_ref(style)
  stylesheet.reference_of(style)
end