Sha256: 8b37817391db525db3a329f62be3dc20519a99aa4ddb71972c6ed0c05802c836
Contents?: true
Size: 856 Bytes
Versions: 9
Compression:
Stored size: 856 Bytes
Contents
class BMC::Serializers::XLSX < BMC::Serializers::Base def render_inline headers, *data = formatted_data SpreadsheetArchitect.to_xlsx( headers: headers, data: data, freeze_headers: true, range_styles: range_styles(data[0]), ) end def render_file(file_path) File.binwrite(file_path, render_inline) end private def range_styles(row) return [] if row.nil? date_range_styles(row) + time_range_styles(row) end def date_range_styles(row) row.each_index.select { row[_1].is_a?(Date) }.map do |col| {range: {rows: :all, columns: col}, styles: {format_code: "dd/mm/yyyy"}} end end def time_range_styles(row) row.each_index.select { row[_1].is_a?(Time) }.map do |col| {range: {rows: :all, columns: col}, styles: {format_code: "dd/mm/yyyy hh:mm:ss"}} end end end
Version data entries
9 entries across 9 versions & 1 rubygems