Permalink
Browse files

Add WrapExcel::Sheet#row_range.

  • Loading branch information...
1 parent b3d14d9 commit b0e15ce0ad2d61c9ce72af38decf1ada0273d6b9 @tomiacannondale committed Feb 20, 2012
Showing with 30 additions and 0 deletions.
  1. +5 −0 lib/wrap_excel/sheet.rb
  2. +25 −0 spec/sheet_spec.rb
@@ -71,6 +71,11 @@ def each_column_with_index(offset = 0)
end
end
+ def row_range(row, range = nil)
+ range ||= 0..@end_column - 1
+ WrapExcel::Range.new(@sheet.Range(@sheet.Cells(row + 1, range.min + 1), @sheet.Cells(row + 1, range.max + 1)))
+ end
+
def method_missing(id, *args)
@sheet.send(id, *args)
end
View
@@ -265,6 +265,31 @@
end
end
+ describe "#row_range" do
+ context "with second argument" do
+ before do
+ @row_range = @sheet.row_range(0, 1..2)
+ end
+
+ it { @row_range.should be_kind_of WrapExcel::Range }
+
+ it "should get range cells of second argument" do
+ @row_range.values.should eq ['workbook', 'sheet1']
+ end
+ end
+
+ context "without second argument" do
+ before do
+ @row_range = @sheet.row_range(2)
+ end
+
+ it "should get all cells" do
+ @row_range.values.should eq ['matz', 'is', 'nice']
+ end
+ end
+
+ end
+
describe "#method_missing" do
it "can access COM method" do
@sheet.Cells(1,1).Value.should eq 'simple'

0 comments on commit b0e15ce

Please sign in to comment.