class OoxmlParser::StyleSheet

Parsing file styles.xml

Attributes

borders[R]

@return [XlsxBorders] Cell XFs

cell_xfs[R]

@return [CellXfs] Cell XFs

differential_formatting_records[R]

@return [DifferentialFormattingRecords] list of differential formatting records

fills[RW]

@return [Fills] fills

fonts[RW]

@return [Fonts] fonts

number_formats[RW]

@return [NumberFormats] number formats

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# 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

Public Instance Methods

parse() click to toggle source

Parse StyleSheet object @return [StyleSheet] result of parsing

# 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