Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/saxlsx/rows_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ def initialize(index, file_system, workbook)
end

def each(&block)
RowsCollectionParser.parse @index, @sheet, @workbook, &block
if block
RowsCollectionParser.parse @index, @sheet, @workbook, &block
else
to_enum
end
end

def count
Expand Down
6 changes: 5 additions & 1 deletion lib/saxlsx/shared_string_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def initialize(file_system)
end

def each(&block)
SharedStringCollectionParser.parse @file_system, &block
if block
SharedStringCollectionParser.parse @file_system, &block
else
to_enum
end
end

end
Expand Down
6 changes: 5 additions & 1 deletion lib/saxlsx/sheet_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def initialize(file_system, workbook)
end

def each(&block)
SheetCollectionParser.parse @file_system, @workbook, &block
if block
SheetCollectionParser.parse @file_system, @workbook, &block
else
to_enum
end
end

end
Expand Down
6 changes: 5 additions & 1 deletion lib/saxlsx/style_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def initialize(file_system)
end

def each(&block)
StyleCollectionParser.parse @file_system, &block
if block
StyleCollectionParser.parse @file_system, &block
else
to_enum
end
end

end
Expand Down
10 changes: 10 additions & 0 deletions spec/sheet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
end
end

it 'handle enumeration' do
indexes = []
Workbook.open filename do |w|
w.sheets[0].rows.each.with_index do |r, i|
indexes << i
end
end
indexes.should eq [0, 1, 2, 3, 4, 5, 6]
end

it 'Rows content' do
Workbook.open filename do |w|
w.sheets[0].tap do |s|
Expand Down