Class: CaxlsxBuilder::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/caxlsx_builder/builder.rb

Constant Summary collapse

CELL_TYPES =

rubocop:disable Naming/VariableNumber I can not change iso_8601 to iso8601 since it is the type expected by Caxlsx.

%i[date time float integer richtext string boolean iso_8601 text].freeze

Instance Method Summary collapse

Constructor Details

#initialize(sheets, options: { rescue_errors: false }, &builder) ⇒ Builder

rubocop:enable Naming/VariableNumber



10
11
12
13
14
15
# File 'lib/caxlsx_builder/builder.rb', line 10

def initialize(sheets, options: { rescue_errors: false }, &builder)
  @sheets  = sheets
  @builder = builder
  @options = options || { rescue_errors: false }
  @styles  = {}
end

Instance Method Details

#callAxlsx::Package

Returns:

  • (Axlsx::Package)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/caxlsx_builder/builder.rb', line 18

def call
  # Creating, initializing and returning the +Axlsx+ package
  Axlsx::Package.new do |package|
    package.use_shared_strings = true

    workbook = package.workbook

    workbook.styles do |styles|
      define_default_styles(styles)

      build_sheets(workbook, styles)
    end
  end
end