Method: RubyExcel::Workbook#delete
- Defined in:
- lib/rubyexcel.rb
#delete(ref = nil) {|RubyExcel::Sheet| ... } ⇒ Object
Removes Sheet(s) from the Workbook
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/rubyexcel.rb', line 123 def delete( ref=nil, &block ) fail ArgumentError, 'Requires either an argument OR a block' if ref && block_given? case ref when nil ; @sheets.reject! { |sht| yield sht } when Fixnum ; @sheets.delete_at( ref - 1 ) when String ; @sheets.reject! { |s| s.name == ref } when Regexp ; @sheets.reject! { |s| s.name =~ ref } when Sheet ; @sheets.reject! { |s| s == ref } else ; fail ArgumentError, 'Unrecognised Argument Type: ' + ref.class.to_s end self end |