class Para::Exporter::Xls
Protected Instance Methods
Source
# File lib/para/exporter/xls.rb, line 54 def encode(string) string.presence && string.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') end
Source
# File lib/para/exporter/xls.rb, line 25 def generate generate_workbook do |workbook| sheet = workbook.create_worksheet # Add headers sheet.row(0).concat headers # Add content rows resources.each_with_index do |resource , index| sheet.row(index + 1).concat row_for(resource) end end end
Source
# File lib/para/exporter/xls.rb, line 39 def generate_workbook(&block) workbook = Spreadsheet::Workbook.new block.call(workbook) buffer = StringIO.new workbook.write(buffer) buffer.rewind buffer.read end
Source
# File lib/para/exporter/xls.rb, line 17 def mime_type 'application/vnd.ms-excel' end