RUBY /的Watir / RASTA:从Excel中/拉斯塔值传递给在Ruby中数组? [英] RUBY/WATIR/RASTA: Pass the value from the excel/rasta to an array in Ruby?

查看:144
本文介绍了RUBY /的Watir / RASTA:从Excel中/拉斯塔值传递给在Ruby中数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Excel中/拉斯塔用逗号分隔值传递给在Ruby中的数组。

How to pass the value separated with comma from the excel/rasta to an array in Ruby.

HTML看起来像这样,
....

html looks like this, ....

<li><input type="checkbox" name="order:1"  />Burger</li>
<li><input type="checkbox" name="order:2"  />Pasta</li>
<li><input type="checkbox" name="order:3"  />Fries</li>

...

EXCEL看起来像这样...

EXCEL looks like this...

订单

汉堡,意大利面

这code不工作

attr_accessor :orders

order = [@orders]
order.each do |i|

.......

........


这应该是这样的红宝石......


It should look like this in ruby...

attr_accessor :orders

orders = [ 'burger','pasta '] *#should pass data from excel in the array "**orders**"

orders.each do |i|
@browser.checkbox(:text => i).click
@browser.button(:name => 'save').click
end

那么,如何会怎么做Excel中的值传递到一个数组中?

So how would i do the passing of the value in excel to an array?

对不起,我还在学习Ruby:|

Sorry, I'm still learning Ruby :|

推荐答案

有一个叫青睐库袋鼠。在链接页面,它会告诉你如何安装库中,然后用它来获取值从Excel中。

There is a favored library called roo. In the linked page, it will tell you how to install the library, then use it to get values out of excel.

require 'rubygems'
require 'roo'

HOURLY_RATE = 123.45

oo = Openoffice.new("simple_spreadsheet.ods")
oo.default_sheet = oo.sheets.first
oo.first_row.upto(oo.last_row) do |line|
  @browser.check(:value => oo.cell(line,'A'))
  @browser.button(:name => 'save').click
end

这篇关于RUBY /的Watir / RASTA:从Excel中/拉斯塔值传递给在Ruby中数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆