Class: Fustrate::Rails::Services::GenerateExcel

Inherits:
Object
  • Object
show all
Defined in:
lib/fustrate/rails/services/generate_excel.rb

Instance Method Summary collapse

Instance Method Details

#call(data, name = 'Sheet 1') ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fustrate/rails/services/generate_excel.rb', line 10

def call(data, name = 'Sheet 1')
  ::Axlsx::Package.new do |package|
    package.use_shared_strings = true

    @wrap = package.workbook.styles.add_style(alignment: { wrap_text: true })

    package.workbook.add_worksheet(name:) { add_data_to_sheet(data, _1) }

    return package.to_stream.read
  end
end