Class: POI::Worksheets
- Inherits:
-
Object
- Object
- POI::Worksheets
- Includes:
- Enumerable
- Defined in:
- lib/poi/workbook/worksheet.rb
Instance Method Summary collapse
- #[](index_or_name) ⇒ Object
- #each ⇒ Object
-
#initialize(workbook) ⇒ Worksheets
constructor
A new instance of Worksheets.
- #size ⇒ Object
Constructor Details
#initialize(workbook) ⇒ Worksheets
Returns a new instance of Worksheets.
5 6 7 8 |
# File 'lib/poi/workbook/worksheet.rb', line 5 def initialize(workbook) @workbook = workbook @poi_workbook = workbook.poi_workbook end |
Instance Method Details
#[](index_or_name) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/poi/workbook/worksheet.rb', line 10 def [](index_or_name) worksheet = case when index_or_name.kind_of?(Numeric) @poi_workbook.get_sheet_at(index_or_name) || @poi_workbook.create_sheet else @poi_workbook.get_sheet(index_or_name) || @poi_workbook.create_sheet(index_or_name) end Worksheet.new(worksheet, @workbook) end |
#each ⇒ Object
24 25 26 |
# File 'lib/poi/workbook/worksheet.rb', line 24 def each (0...size).each { |i| yield Worksheet.new(@poi_workbook.get_sheet_at(i), @workbook) } end |
#size ⇒ Object
20 21 22 |
# File 'lib/poi/workbook/worksheet.rb', line 20 def size @poi_workbook.number_of_sheets end |