diff --git a/lib/roo/excelx/sheet_doc.rb b/lib/roo/excelx/sheet_doc.rb
index adbb77a8..215abae8 100755
--- a/lib/roo/excelx/sheet_doc.rb
+++ b/lib/roo/excelx/sheet_doc.rb
@@ -44,6 +44,8 @@ def each_row_streaming(&block)
# Yield each cell as Excelx::Cell to caller for given
# row xml
def each_cell(row_xml)
+ return to_enum(:each_cell, row_xml) unless block_given?
+
return [] unless row_xml
row_xml.children.each do |cell_element|
coordinate = ::Roo::Utils.extract_coordinate(cell_element["r"])
@@ -111,7 +113,7 @@ def cell_from_xml(cell_xml, hyperlink, coordinate, empty_cell=true)
format = style_format(style)
value_type = cell_value_type(cell_xml["t"], format)
- return create_cell_from_value(value_type, cell, formula, format, style, hyperlink, coordinate)
+ return create_cell_from_value(value_type, cell, formula, format, style, hyperlink, coordinate) unless cell.content.empty?
end
end
diff --git a/spec/lib/roo/excelx/sheet_doc_spec.rb b/spec/lib/roo/excelx/sheet_doc_spec.rb
index 3dc3e93d..83b85d3b 100644
--- a/spec/lib/roo/excelx/sheet_doc_spec.rb
+++ b/spec/lib/roo/excelx/sheet_doc_spec.rb
@@ -8,4 +8,27 @@
example "#last_row" do
expect(subject.last_row).to eq 3
end
+
+ describe "#each_cell" do
+ let(:relationships) { instance_double(Roo::Excelx::Relationships, include_type?: false) }
+ let(:styles) { instance_double(Roo::Excelx::Styles, style_format: 'General') }
+ let(:shared) { instance_double(Roo::Excelx::Shared, styles: styles) }
+ let(:sheet_doc) { described_class.new(nil, relationships, shared) }
+
+ context "empty v element" do
+ let(:row_xml) { Nokogiri.parse('
').root }
+
+ it "returns an empty cell" do
+ expect(sheet_doc.each_cell(row_xml)).to all(be_a(Roo::Excelx::Cell::Empty))
+ end
+ end
+
+ context "no v element" do
+ let(:row_xml) { Nokogiri.parse('
').root }
+
+ it "returns an empty cell" do
+ expect(sheet_doc.each_cell(row_xml)).to all(be_a(Roo::Excelx::Cell::Empty))
+ end
+ end
+ end
end