Method: RubyExcel.borders
- Defined in:
- lib/rubyexcel/excel_tools.rb
.borders(range, weight = 1, inner = false) ⇒ WIN32OLE::Range
Add borders to an Excel Range
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubyexcel/excel_tools.rb', line 19 def self.borders( range, weight=1, inner=false ) range.ole_respond_to?( :borders ) or fail ArgumentError, 'First Argument must be WIN32OLE Range' [0,1,2,3].include?( weight ) or fail ArgumentError, "Invalid line weight #{ weight }. Must be from 0 to 3" defined?( ExcelConstants::XlEdgeLeft ) or WIN32OLE.const_load( range.application, ExcelConstants ) consts = [ ExcelConstants::XlEdgeLeft, ExcelConstants::XlEdgeTop, ExcelConstants::XlEdgeBottom, ExcelConstants::XlEdgeRight, ExcelConstants::XlInsideVertical, ExcelConstants::XlInsideHorizontal ] inner or consts.pop(2) weight = [ 0, ExcelConstants::XlThin, ExcelConstants::XlMedium, ExcelConstants::XlThick ][ weight ] consts.each { |const| weight.zero? ? range.Borders( const ).linestyle = ExcelConstants::XlNone : range.Borders( const ).weight = weight } range end |