Class: OoxmlParser::Chartsheet

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

Overview

Class for storing data of chartsheets files

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) ⇒ Chartsheet

Returns a new instance of Chartsheet.



9
10
11
12
# File 'lib/ooxml_parser/xlsx_parser/workbook/chartsheet.rb', line 9

def initialize(parent: nil)
  @sheet_views = []
  super
end

Instance Attribute Details

#sheet_viewsArray, SheetView

Returns array of views.

Returns:



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/workbook/chartsheet.rb', line 7

def sheet_views
  @sheet_views
end

Instance Method Details

#parse(file) ⇒ Chartsheet

Parse Chartsheet object

Parameters:

  • file (String)

    file to parse

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ooxml_parser/xlsx_parser/workbook/chartsheet.rb', line 17

def parse(file)
  root_object.add_to_xmls_stack(root_object.root_subfolder + file)
  doc = parse_xml(root_object.current_xml)
  node = doc.xpath('//xmlns:chartsheet').first
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'sheetViews'
      node_child.xpath('*').each do |view_child|
        @sheet_views << SheetView.new(parent: self).parse(view_child)
      end
    end
  end
  root_object.xmls_stack.pop
  self
end