examples/example.rb in axlsx-1.3.6 vs examples/example.rb in axlsx-2.0.0

- old
+ new

@@ -44,10 +44,12 @@ examples << :conditional_formatting examples << :streaming examples << :shared_strings examples << :no_autowidth examples << :cached_formula +examples << :page_breaks + p = Axlsx::Package.new wb = p.workbook #``` ## A Simple Workbook @@ -55,10 +57,11 @@ #```ruby if examples.include? :basic wb.add_worksheet(:name => "Basic Worksheet") do |sheet| sheet.add_row ["First Column", "Second", "Third"] sheet.add_row [1, 2, 3] + sheet.add_row [' preserving whitespace'] end end #``` #Using Custom Styles @@ -307,10 +310,11 @@ ##Asian Language Support #```ruby if examples.include? :mbcs + wb.styles.fonts.first.name = 'Arial Unicode MS' wb.add_worksheet(:name => "日本語でのシート名") do |sheet| sheet.add_row ["日本語"] sheet.add_row ["华语/華語"] sheet.add_row ["한국어/조선말"] end @@ -638,10 +642,11 @@ pane.y_split = 4 end end end + # conditional formatting # if examples.include? :conditional_formatting percent = wb.styles.add_style(:format_code => "0.00%", :border => Axlsx::STYLE_THIN_BORDER) money = wb.styles.add_style(:format_code => '0,000', :border => Axlsx::STYLE_THIN_BORDER) @@ -708,10 +713,20 @@ icon_set = Axlsx::IconSet.new sheet.add_conditional_formatting("B3:B100", { :type => :iconSet, :dxfId => profitable, :priority => 1, :icon_set => icon_set }) end end -##Validate and Serialize +# Page Breaks +if examples.include? :page_breaks + ws = wb.add_worksheet(:name => "page breaks") do |sheet| + sheet.add_row ["A"] * 10 + sheet.add_row ["A"] * 10 + sheet.add_page_break("B2") + sheet.sheet_view.view = :page_layout # so you can see the breaks! + end +end + +#Validate and Serialize #```ruby # Serialize directly to file p.serialize("example.xlsx")