Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add WrapExcel::Sheet#col_range.

  • Loading branch information...
commit bf898dc15e45b2563048866d03eb092c22d59b39 1 parent b0e15ce
@tomiacannondale authored
Showing with 30 additions and 0 deletions.
  1. +5 −0 lib/wrap_excel/sheet.rb
  2. +25 −0 spec/sheet_spec.rb
View
5 lib/wrap_excel/sheet.rb
@@ -76,6 +76,11 @@ def row_range(row, range = nil)
WrapExcel::Range.new(@sheet.Range(@sheet.Cells(row + 1, range.min + 1), @sheet.Cells(row + 1, range.max + 1)))
end
+ def col_range(col, range = nil)
+ range ||= 0..@end_row - 1
+ WrapExcel::Range.new(@sheet.Range(@sheet.Cells(range.min + 1, col + 1), @sheet.Cells(range.max + 1, col + 1)))
+ end
+
def method_missing(id, *args)
@sheet.send(id, *args)
end
View
25 spec/sheet_spec.rb
@@ -290,6 +290,31 @@
end
+ describe "#col_range" do
+ context "with second argument" do
+ before do
+ @col_range = @sheet.col_range(0, 1..2)
+ end
+
+ it { @col_range.should be_kind_of WrapExcel::Range }
+
+ it "should get range cells of second argument" do
+ @col_range.values.should eq ['foo', 'matz']
+ end
+ end
+
+ context "without second argument" do
+ before do
+ @col_range = @sheet.col_range(1)
+ end
+
+ it "should get all cells" do
+ @col_range.values.should eq ['workbook', nil, 'is']
+ end
+ end
+
+ end
+
describe "#method_missing" do
it "can access COM method" do
@sheet.Cells(1,1).Value.should eq 'simple'
Please sign in to comment.
Something went wrong with that request. Please try again.