43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
# encoding: utf-8
|
|
|
|
wb = xlsx_package.workbook
|
|
|
|
wb.add_worksheet(name: @excel_title) do |sheet|
|
|
|
|
row = []
|
|
|
|
@table_headers.each do |h|
|
|
row << h['head-title']
|
|
end
|
|
highlight_style = wb.styles.add_style(
|
|
:bg_color => 'ffeb3b',
|
|
:b => true,
|
|
:border => { :style => :thick, :color => "000000", :edges => [:top, :left, :bottom, :right] },
|
|
:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}
|
|
)
|
|
sheet.add_row row, :style => (0...row.count).collect{ highlight_style }
|
|
|
|
|
|
date_time_style = wb.styles.add_style({:format_code => 'yyyy/mm/dd hh:mm', :alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}})
|
|
wrap_text_style = wb.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}})
|
|
# types = [:time]
|
|
# styles = [date_time_style]
|
|
types = []
|
|
styles = []
|
|
@asia_data_list.each_with_index do |data, i|
|
|
row2 = []
|
|
data.each do |v|
|
|
row2 << v
|
|
end
|
|
if i == 0
|
|
(0...(row2.count)).each do |i|
|
|
types << :string
|
|
styles << wrap_text_style
|
|
end
|
|
end
|
|
sheet.add_row row2 , :types => types, :style => styles
|
|
end
|
|
|
|
end
|
|
|