examples/example.rb in axlsx-1.1.1 vs examples/example.rb in axlsx-1.1.2

- old
+ new

@@ -40,11 +40,11 @@ ##Using Custom Formatting and date1904 require 'date' wb.styles do |s| date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER) padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER) - percent = s.add_style(:format_code => "0000%", :border => Axlsx::STYLE_THIN_BORDER) + percent = s.add_style(:format_code => "###0%", :border => Axlsx::STYLE_THIN_BORDER) # wb.date1904 = true # Use the 1904 date system (Used by Excel for Mac < 2011) wb.add_worksheet(:name => "Formatting Data") do |sheet| sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded] end @@ -144,11 +144,13 @@ ##Automatic cell types wb.add_worksheet(:name => "Automatic cell types") do |sheet| sheet.add_row ["Date", "Time", "String", "Boolean", "Float", "Integer"] - sheet.add_row [Date.today, Time.now, "value", true, 0.1, 1] + date_format = wb.styles.add_style :format_code => 'YYYY-MMM-DD' + time_format = wb.styles.add_style :format_code => 'HH:MM:SS' + sheet.add_row [Date.today, Time.now, "value", true, 0.1, 1], :style => [date_format, time_format] end ##Merging Cells. wb.add_worksheet(:name => 'Merging Cells') do |sheet| @@ -168,9 +170,11 @@ sheet.add_row ["A Simple Bar Chart"] sheet.add_row ["First", "Second", "Third"] sheet.add_row [1, 2, 3] sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart| chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"] + chart.valAxis.label_rotation = -45 + chart.catAxis.label_rotation = 45 end end ##Hide Gridlines in chart wb.add_worksheet(:name => "Chart With No Gridlines") do |sheet|