module ExcelSerializer::Writer
Private Instance Methods
adapter()
click to toggle source
# File lib/excel_serializer/writer.rb, line 50 def adapter case self.class.current_config.excel_adapter when :write_excel ::ExcelSerializer::Adapters::WriteExcel else raise "Invalid excel writer adapter" end end
add_headers(sheet_name)
click to toggle source
# File lib/excel_serializer/writer.rb, line 10 def add_headers(sheet_name) sheet(sheet_name).write_headers(headers) end
close_workbook()
click to toggle source
# File lib/excel_serializer/writer.rb, line 45 def close_workbook current_excel.save return file_path end
current_excel()
click to toggle source
# File lib/excel_serializer/writer.rb, line 14 def current_excel return @current_excel if @current_excel.present? @current_excel = adapter.new(file_path) end
file_path()
click to toggle source
# File lib/excel_serializer/writer.rb, line 41 def file_path @file_path end
file_path=(file_path)
click to toggle source
# File lib/excel_serializer/writer.rb, line 33 def file_path=(file_path) if file_path.blank? @file_path = "/tmp/#{SecureRandom.uuid}#{adapter.file_extension}" else @file_path= file_path end end
sheet(sheet_name)
click to toggle source
# File lib/excel_serializer/writer.rb, line 23 def sheet(sheet_name) @sheets ||= {} @sheets[sheet_name]= worksheet(sheet_name) if @sheets[sheet_name].blank? @sheets[sheet_name] end
worksheet(sheet_name)
click to toggle source
# File lib/excel_serializer/writer.rb, line 29 def worksheet(sheet_name) ::ExcelSerializer::Worksheet.new(current_excel, sheet_name) end
write(sheet_name, row)
click to toggle source
# File lib/excel_serializer/writer.rb, line 19 def write(sheet_name, row) sheet(sheet_name).write_row(row) end