You could do the following:
sheet1 = book.worksheet 0
0.upto(sheet1.column_count) do |column|
sheet1.column(column).to_a.compact.each do |cell_text|
@browser.link(:href => cell_text).when_present.click
end
end
Explanation:
sheet1.column_count
tells you how many columns there are.sheet1.column(column)
gets a column at the specified index (0-based).sheet1.column(column).to_a
gets all of the values in the column. The number of rows in a column is based on the column with the most number of rows. Therefore, some of the columns are likely to have blank value at the end. The.compact
is used to remove these.