Sha256: 06094d2562b0276813323b11feffafe542652e0460e6943d6e186be893b21f1a
Contents?: true
Size: 1.72 KB
Versions: 8
Compression:
Stored size: 1.72 KB
Contents
wb = xlsx_package.workbook #styles styles = {} styles[:table_header] = wb.styles.add_style :style => :thick, :bg_color => "EEEEEE" styles[:bold] = wb.styles.add_style :style => :thick styles[:title] = wb.styles.add_style :sz => 14, :alignment => { :horizontal => :center}, :style => :thick styles[:subtitle] = wb.styles.add_style :sz => 12, :alignment => { :horizontal => :center}, :style => :thick wb.add_worksheet(name: @report[:title][0,31].gsub(/[:\/]/,'-'), page_margins: convert_margins_to_xlsx(@report[:page_margin])) do |sheet| first_table = @report[:tables].values.first columns = first_table.blank? ? 12 : first_table.first.length last_column = to_xls_col(columns) render :partial => "meta_reports/default_header", :locals => { :sheet => sheet, :title => @report[:title], :subtitle => @report[:subtitle], :columns => columns, :styles => styles } if @report[:description] sheet.add_row [@report[:description]] this_rows = sheet.rows.length sheet.merge_cells("A#{this_rows}:#{last_column}#{this_rows}") end table_names = @report[:table_order] || @report[:tables].keys.sort_by {|k| k.to_s} table_names.each do |table_name| table = @report[:tables][table_name] opts = table.last.is_a?(Hash) ? table.pop : {} row_classes = opts[:row_classes] || {} sheet.add_row [' '] * columns this_rows = sheet.rows.length sheet.add_row [table_name] + [' ']*(columns-1) sheet.merge_cells("A#{this_rows}:#{last_column}#{this_rows}") styling = {} unless @report[:table_header] == false prep_xlsx_table([table.shift], styling).each do |row| sheet.add_row row, :style => styles[:table_header] end end prep_xlsx_table(table, styling).each do |row| sheet.add_row row #TODO: handle styling end end end
Version data entries
8 entries across 4 versions & 1 rubygems