From bfac5e8cb64783e55c69b7ab26c5050a6c9e7ebe Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Thu, 23 Aug 2012 08:19:57 +0900 Subject: show how to do border edges in the exempts and update docs in stylesheet --- examples/example.rb | 5 +++-- lib/axlsx/stylesheet/styles.rb | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/example.rb b/examples/example.rb index eb9d1a15..6f4daec3 100755 --- a/examples/example.rb +++ b/examples/example.rb @@ -62,8 +62,8 @@ end #```ruby #Axlsx defines a thin border style, but you can easily create and use your own. wb.styles do |s| - red_border = s.add_style :border => { :style => :thick, :color =>"FFFF0000" } - blue_border = s.add_style :border => { :style => :thick, :color =>"FF0000FF" } + red_border = s.add_style :border => { :style => :thick, :color =>"FFFF0000", :edges => [:left, :right] } + blue_border = s.add_style :border => { :style => :thick, :color =>"FF0000FF"} wb.add_worksheet(:name => "Custom Borders") do |sheet| sheet.add_row ["wrap", "me", "Up in Red"], :style => red_border @@ -195,6 +195,7 @@ end ##Automatic cell types + #```ruby wb.add_worksheet(:name => "Automatic cell types") do |sheet| date_format = wb.styles.add_style :format_code => 'YYYY-MM-DD' diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index 1b22bb81..0532af66 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -135,6 +135,7 @@ module Axlsx # @option options [Integer] num_fmt The number format to apply # @option options [String] format_code The formatting to apply. # @option options [Integer|Hash] border The border style to use. + # borders support style, color and edges options @see parse_border_options # @option options [String] bg_color The background color to apply to the cell # @option options [Boolean] hidden Indicates if the cell should be hidden # @option options [Boolean] locked Indicates if the cell should be locked @@ -298,7 +299,11 @@ module Axlsx # parses Style#add_style options for borders. # @note noop if :border is not specified in options - # @option options [Hash|Integer] A border style definition hash or the index of an existing border. Border style definition hashes must include :style and color: key-value entries and may include an :edges entry that references an array of symbols identifying which border edges you wish to apply the style or any other valid Border initializer options. If the :edges entity is not provided the style is applied to all edges of cells that reference this style. + # @option options [Hash|Integer] A border style definition hash or the index of an existing border. + # Border style definition hashes must include :style and :color key-value entries and + # may include an :edges entry that references an array of symbols identifying which border edges + # you wish to apply the style or any other valid Border initializer options. + # If the :edges entity is not provided the style is applied to all edges of cells that reference this style. # @example # #apply a thick red border to the top and bottom # { :border => { :style => :thick, :color => "FFFF0000", :edges => [:top, :bottom] } -- cgit v1.2.3