Class: Axlsx::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/barkest_core/extensions/axlsx_extenstions.rb

Overview

The Package class is used to manage the Excel file in memory.

Instance Method Summary collapse

Instance Method Details

#barkest_core_original_workbookObject



26
# File 'lib/barkest_core/extensions/axlsx_extenstions.rb', line 26

alias :barkest_core_original_workbook :workbook

#simple(name = nil) ⇒ Object

Creates a simple workbook with one sheet.

Predefines multiple styles that can be used to format cells. The sheet and styles are yielded to the provided block.

See Axlsx::Workbook#predefined_styles for a list of predefined styles.



19
20
21
22
23
24
# File 'lib/barkest_core/extensions/axlsx_extenstions.rb', line 19

def simple(name = nil)
  workbook.add_worksheet(name: name || 'Sheet 1') do |sheet|
    yield sheet, workbook.predefined_styles if block_given?
    sheet.add_row
  end
end

#workbook {|@workbook| ... } ⇒ Object

:nodoc:

Yields:



29
30
31
32
33
34
# File 'lib/barkest_core/extensions/axlsx_extenstions.rb', line 29

def workbook
  @workbook ||= Workbook.new
  @workbook.package = self
  yield @workbook if block_given?
  @workbook
end