Class: OoxmlParser::StyleSheet

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb

Overview

Parsing file styles.xml

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ StyleSheet

Returns a new instance of StyleSheet.



25
26
27
28
29
30
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb', line 25

def initialize(parent: nil)
  @number_formats = NumberFormats.new(parent: self)
  @fonts = Fonts.new(parent: self)
  @fills = Fills.new(parent: self)
  super
end

Instance Attribute Details

#bordersXlsxBorders (readonly)

Returns Cell XFs.

Returns:



21
22
23
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb', line 21

def borders
  @borders
end

#cell_xfsCellXfs (readonly)

Returns Cell XFs.

Returns:



19
20
21
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb', line 19

def cell_xfs
  @cell_xfs
end

#differential_formatting_recordsDifferentialFormattingRecords (readonly)

Returns list of differential formatting records.

Returns:



23
24
25
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb', line 23

def differential_formatting_records
  @differential_formatting_records
end

#fillsFills

Returns fills.

Returns:



17
18
19
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb', line 17

def fills
  @fills
end

#fontsFonts

Returns fonts.

Returns:



15
16
17
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb', line 15

def fonts
  @fonts
end

#number_formatsNumberFormats

Returns number formats.

Returns:



13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb', line 13

def number_formats
  @number_formats
end

Instance Method Details

#parseStyleSheet

Parse StyleSheet object

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb', line 34

def parse
  doc = parse_xml("#{root_object.unpacked_folder}/#{root_object.root_subfolder}/styles.xml")
  doc.root.xpath('*').each do |node_child|
    case node_child.name
    when 'numFmts'
      @number_formats.parse(node_child)
    when 'fonts'
      @fonts.parse(node_child)
    when 'fills'
      @fills.parse(node_child)
    when 'cellXfs'
      @cell_xfs = CellXfs.new(parent: self).parse(node_child)
    when 'borders'
      @borders = XlsxBorders.new(parent: self).parse(node_child)
    when 'dxfs'
      @differential_formatting_records = DifferentialFormattingRecords.new(parent: self).parse(node_child)
    end
  end
  self
end