Sha256: d6e36e939630c1cf31f11b4e86b39685eebda85302c3fe3cd908e771d1aaa0d6

Contents?: true

Size: 1.79 KB

Versions: 16

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require_relative 'style_sheet/cell_xfs'
require_relative 'style_sheet/fills'
require_relative 'style_sheet/fonts'
require_relative 'style_sheet/number_formats'
require_relative 'style_sheet/xlsx_borders'
require_relative 'style_sheet/differential_formatting_records'
module OoxmlParser
  # Parsing file styles.xml
  class StyleSheet < OOXMLDocumentObject
    # @return [NumberFormats] number formats
    attr_accessor :number_formats
    # @return [Fonts] fonts
    attr_accessor :fonts
    # @return [Fills] fills
    attr_accessor :fills
    # @return [CellXfs] Cell XFs
    attr_reader :cell_xfs
    # @return [XlsxBorders] Cell XFs
    attr_reader :borders
    # @return [DifferentialFormattingRecords] list of differential formatting records
    attr_reader :differential_formatting_records

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

    # Parse StyleSheet object
    # @return [StyleSheet] result of parsing
    def parse
      doc = parse_xml("#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.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
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ooxml_parser-0.29.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb
ooxml_parser-0.28.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb
ooxml_parser-0.27.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb
ooxml_parser-0.26.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb
ooxml_parser-0.25.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb
ooxml_parser-0.24.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet.rb
ooxml_parser-0.23.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.22.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.21.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.20.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.19.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.18.1 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.18.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.17.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.16.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.15.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb