diff options
| author | Randy Morgan <[email protected]> | 2012-11-05 08:15:31 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-11-05 08:15:31 +0900 |
| commit | 2c9cfc269f0e0e8088d51873a3f6593fcf3c0941 (patch) | |
| tree | 8a7c48c486ca77d95c45807001a70d6b49b82789 /examples | |
| parent | 2feca4f74f21e6a3e63bd3badd02267be4062047 (diff) | |
| download | caxlsx-2c9cfc269f0e0e8088d51873a3f6593fcf3c0941.tar.gz caxlsx-2c9cfc269f0e0e8088d51873a3f6593fcf3c0941.zip | |
added example for surrounding border
Diffstat (limited to 'examples')
| -rwxr-xr-x | examples/example.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/example.rb b/examples/example.rb index 3a685657..d85ba27f 100755 --- a/examples/example.rb +++ b/examples/example.rb @@ -9,6 +9,7 @@ examples << :basic examples << :custom_styles examples << :cell_style_override examples << :custom_borders +examples << :surrounding_border examples << :deep_custom_borders examples << :row_column_style examples << :fixed_column_width @@ -111,6 +112,33 @@ if examples.include? :custom_borders end end +#```ruby +# More Custom Borders +if examples.include? :surrounding_border + + # Stuff like this is why I LOVE RUBY + # If you dont know about hash default values + # LEARN IT! LIVE IT! LOVE IT! + defaults = { :style => :thick, :color => "000000" } + borders = Hash.new do |hash, key| + hash[key] = wb.styles.add_style :border => defaults.merge( { :edges => key.to_s.split('_').map(&:to_sym) } ) + end + top_row = [0, borders[:top_left], borders[:top], borders[:top], borders[:top_right]] + middle_row = [0, borders[:left], nil, nil, borders[:right]] + bottom_row = [0, borders[:bottom_left], borders[:bottom], borders[:bottom], borders[:bottom_right]] + + wb.add_worksheet(:name => "Surrounding Border") do |ws| + ws.add_row [] + ws.add_row ['', 1,2,3,4], :style => top_row + ws.add_row ['', 5,6,7,8], :style => middle_row + ws.add_row ['', 9, 10, 11, 12] + + #This works too! + ws.rows.last.style = bottom_row + + end +end + #```ruby # Hacking border styles if examples.include? :deep_custom_borders |
