Sha256: 76455a8c108241ab9ba6fe31e0bcc34343c9e475878acb688bc58370b11d8dec

Contents?: true

Size: 1.47 KB

Versions: 12

Compression:

Stored size: 1.47 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'
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

    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)
        end
      end
      self
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ooxml_parser-0.14.2 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.14.1 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.14.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.13.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.12.2 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.12.1 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.12.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.11.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.10.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.9.1 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
ooxml_parser-0.9.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb