diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | examples/skydrive/real_example.rb | 12 | ||||
| -rw-r--r-- | examples/sprk2012/basics.rb | 1 | ||||
| -rw-r--r-- | examples/sprk2012/images.rb | 19 | ||||
| -rw-r--r-- | examples/sprk2012/styles.rb | 25 |
5 files changed, 28 insertions, 30 deletions
@@ -12,3 +12,4 @@ example.csv tmp *.pem *.pfx +examples/sprk2012 diff --git a/examples/skydrive/real_example.rb b/examples/skydrive/real_example.rb index ab74fa7f..bd72b56c 100644 --- a/examples/skydrive/real_example.rb +++ b/examples/skydrive/real_example.rb @@ -5,14 +5,14 @@ require 'axlsx' Axlsx::Package.new do |p| p.workbook do |wb| styles = wb.styles - header = styles.add_style :bg_color => "DD", :sz => 16, :b => true, :alignment => {:horizontal => :center} + header = styles.add_style :bg_color => "DD", :sz => 16, :b => true, :alignment => {:horizontal => :center} tbl_header = styles.add_style :b => true, :alignment => { :horizontal => :center } ind_header = styles.add_style :bg_color => "FFDFDEDF", :b => true, :alignment => {:indent => 1} - col_header = styles.add_style :bg_color => "FFDFDEDF", :b => true, :alignment => { :horizontal => :center } - label = styles.add_style :alignment => { :indent => 1 } - money = styles.add_style :num_fmt => 5 - t_label = styles.add_style :b => true, :bg_color => "FFDFDEDF" - t_money = styles.add_style :b => true, :num_fmt => 5, :bg_color => "FFDFDEDF" + col_header = styles.add_style :bg_color => "FFDFDEDF", :b => true, :alignment => { :horizontal => :center } + label = styles.add_style :alignment => { :indent => 1 } + money = styles.add_style :num_fmt => 5 + t_label = styles.add_style :b => true, :bg_color => "FFDFDEDF" + t_money = styles.add_style :b => true, :num_fmt => 5, :bg_color => "FFDFDEDF" wb.add_worksheet do |sheet| sheet.add_row diff --git a/examples/sprk2012/basics.rb b/examples/sprk2012/basics.rb index 8f5cb543..82c56a4e 100644 --- a/examples/sprk2012/basics.rb +++ b/examples/sprk2012/basics.rb @@ -1,3 +1,4 @@ +$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" require 'axlsx' package = Axlsx::Package.new diff --git a/examples/sprk2012/images.rb b/examples/sprk2012/images.rb index d7fc768e..6e0b306d 100644 --- a/examples/sprk2012/images.rb +++ b/examples/sprk2012/images.rb @@ -1,14 +1,9 @@ -require 'axlsx' -package = Axlsx::Package.new -workbook = package.workbook +$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" -workbook.add_worksheet(:name => "Image with Hyperlink") do |sheet| - img = File.expand_path('../image1.jpeg', __FILE__) - sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image| - image.width=720 - image.height=666 - image.hyperlink.tooltip = "Labeled Link" - image.start_at 2, 2 +require 'axlsx' +package = Axlsx::Package.new do |package| + package.workbook.add_worksheet(:name => "imagex") do |sheet| + img_path = File.expand_path('../../image1.jpeg', __FILE__) + sheet.add_image(:image_src => img_path, :width => 720, :height => 666, :start_at => [2,2]) end -end - +end.serialize 'images.xlsx' diff --git a/examples/sprk2012/styles.rb b/examples/sprk2012/styles.rb index e9ff6a9e..ce1bf2a0 100644 --- a/examples/sprk2012/styles.rb +++ b/examples/sprk2012/styles.rb @@ -1,19 +1,20 @@ +$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" + require 'axlsx' package = Axlsx::Package.new -workbook = package.workbook - -workbook.styles do |s| - - black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center } - blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center } - - wb.add_worksheet(:name => "Styles") do |sheet| +package.workbook do |workbook| + workbook.styles do |s| + black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center } + blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center } - # Applies the black_cell style to the first and third cell, and the blue_cell style to the second. - sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell] + workbook.add_worksheet(:name => "Styles") do |sheet| + # Applies the black_cell style to the first and third cell, and the blue_cell style to the second. + sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell] - # Applies the thin border to all three cells - sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER + # Applies the thin border to all three cells + sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER + end end end +package.serialize 'styles.xlsx' |
