Class: ActiveList::Exporters::OpenDocumentSpreadsheetExporter
Instance Attribute Summary
#generator, #table
Instance Method Summary
collapse
#columns_headers, #columns_to_array, #columns_to_hash, #file_name_code, #generate_file_code, #initialize
Instance Method Details
#file_extension ⇒ Object
12
13
14
|
# File 'lib/active_list/exporters/open_document_spreadsheet_exporter.rb', line 12
def file_extension
'ods'
end
|
#generate_data_code ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/active_list/exporters/open_document_spreadsheet_exporter.rb', line 20
def generate_data_code
record = 'r'
code = generator.select_data_code(paginate: false)
code << <<~RUBY
records = #{generator.records_variable_name}
data = RODF::Spreadsheet.new
data.instance_eval do
office_style :head, family: :cell do
property :text, 'font-weight': :bold
property :paragraph, 'text-align': :center
end
table #{table.model.name}.model_name.human do
row do
#{columns_to_array(:)}.each do |header|
cell header, style: :head
end
end
for #{record} in records
row do
#{columns_to_array(:body, record: record)}.each do |value|
cell value
end
end
end
end
end
RUBY
code.c
end
|
#mime_type ⇒ Object
16
17
18
|
# File 'lib/active_list/exporters/open_document_spreadsheet_exporter.rb', line 16
def mime_type
Mime[:ods]
end
|
#send_data_code ⇒ Object
54
55
56
|
# File 'lib/active_list/exporters/open_document_spreadsheet_exporter.rb', line 54
def send_data_code
"send_data(data.bytes, type: #{mime_type.to_s.inspect}, disposition: 'inline', filename: file_name.parameterize + '.#{file_extension}')\n".c
end
|