Class: Agilibox::Serializers::AXLSX

Inherits:
Base
  • Object
show all
Defined in:
app/serializers/agilibox/serializers/axlsx.rb

Instance Attribute Summary

Attributes inherited from Base

#data, #options

Instance Method Summary collapse

Methods inherited from Base

format, format_boolean, format_datetime, format_decimal, format_default, format_integer, #formatted_data, formatter_for, #initialize

Constructor Details

This class inherits a constructor from Agilibox::Serializers::Base

Instance Method Details

#render_file(file_path) ⇒ Object



6
7
8
# File 'app/serializers/agilibox/serializers/axlsx.rb', line 6

def render_file(file_path)
  xlsx.serialize(file_path)
end

#render_inlineObject



2
3
4
# File 'app/serializers/agilibox/serializers/axlsx.rb', line 2

def render_inline
  xlsx.to_stream.read.force_encoding("BINARY")
end

#xlsxObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/serializers/agilibox/serializers/axlsx.rb', line 10

def xlsx
  @xlsx ||= Axlsx::Package.new do |p|
    p.workbook.add_worksheet do |sheet|
      formatted_data.each do |line|
        sheet.add_row(line)
      end
    end

    p.use_shared_strings = true
  end
end