Class: OpenXML::SpreadsheetML::Workbook

Inherits:
Struct
  • Object
show all
Defined in:
lib/xlsx/workbook.rb,
lib/xlsx/workbook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#calc_chainObject

Returns the value of attribute calc_chain

Returns:

  • (Object)

    the current value of calc_chain



3
4
5
# File 'lib/xlsx/workbook.rb', line 3

def calc_chain
  @calc_chain
end

#sheetsObject

Returns the value of attribute sheets

Returns:

  • (Object)

    the current value of sheets



3
4
5
# File 'lib/xlsx/workbook.rb', line 3

def sheets
  @sheets
end

#stylesObject

Returns the value of attribute styles

Returns:

  • (Object)

    the current value of styles



3
4
5
# File 'lib/xlsx/workbook.rb', line 3

def styles
  @styles
end

#themeObject

Returns the value of attribute theme

Returns:

  • (Object)

    the current value of theme



3
4
5
# File 'lib/xlsx/workbook.rb', line 3

def theme
  @theme
end

#xml_mapsObject

Returns the value of attribute xml_maps

Returns:

  • (Object)

    the current value of xml_maps



3
4
5
# File 'lib/xlsx/workbook.rb', line 3

def xml_maps
  @xml_maps
end

Class Method Details

.parser(content) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/xlsx/workbook.rb', line 25

def self.parser content
  sheets = []
  doc = Nokogiri::XML content
  sheet_tags = doc.css('sheet')
  sheet_tags.each do |s|
    sheet = Sheet.new
    sheet.name = s[:name]
    sheet.sheetId = s[:sheetId]
    sheet.rid = s['r:id']
    sheets << sheet
  end
  Workbook.new(sheets = sheets)
end

Instance Method Details

#[](index) ⇒ Object



9
10
11
12
13
14
# File 'lib/xlsx/workbook.rb', line 9

def [] index
  self.sheets.each do |sheet|
    return sheet if sheet.name == index
  end
  nil
end

#merge_sheets(sheets) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/xlsx/workbook.rb', line 16

def merge_sheets sheets
  new_sheets = []
  self.sheets.zip(sheets) do |x, y|
    new_sheets << x + y
  end
  self.sheets = new_sheets
  self
end