wb = xlsx_package.workbook
letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
@date_format='%d-%b-%Y %H:%M:%S'
wb.add_worksheet(name: "Report") do |sheet|

  title_style= wb.styles.add_style :bg_color => "c0392b", :fg_color => "FFF", :sz => 20, :alignment => {:vertical => :center }
  period_style= wb.styles.add_style :bg_color => "c0392b", :fg_color => "FFF", :sz => 16, :alignment => {:vertical => :center}, :border => { :style => :thick, :color =>"FFF", :edges => [:left] }
  
  sheet.add_row [@title,@period],:style => [title_style,period_style], :height => 50
  sheet.merge_cells "#{letters[1]}1:#{letters[@header.length-1]}1"
  
  common_cell = wb.styles.add_style(:sz => 14, :alignment => {:vertical => :center}, :fg_color => "34495e")
  time = wb.styles.add_style(:format_code => 'yyyy.MM.dd hh:mm:ss', :sz => 14, :alignment => {:vertical => :center}, :fg_color => "34495e")
  red_cell = wb.styles.add_style :bg_color => "c0392b", :fg_color => "FFF", :sz => 16, :alignment => { :horizontal=> :center, :vertical => :center }, :border => { :style => :thick, :color =>"FFF", :edges => [:top] }
  sheet.add_row @header, :style => red_cell, :height => 30
  style_array=[]
  @body_data.each do |item|
		if item == 'start_time' || item == 'end_time'
			style_array.push(time)
		else
			style_array.push(common_cell)
		end
  end	
  @array.each do |button|
	temp_array=[]
	@body_data.each do |item|
		if (button[item]).class == ActiveSupport::TimeWithZone
			@time=Time::strptime(button[item].strftime(@date_format),@date_format)
			temp_array.push(@time)
		else
			temp_array.push(button[item])
		end
	end	
	sheet.add_row temp_array, :style => style_array, :height => 20
  end
end
wb.use_shared_strings = true