Well give you the simple example based on xls.rb
You can download an excel interface file called xls.rb from f*rom xls*
.rubyforge.org/svn/trunk/xls.rb.
The project looks inactive, maybe a member of the group knows another
source for the file or what the status of the project is.
Once xls.rb is download copy it into your project file. Then try the
sample code
Assume our range in the worksheet in the spreadsheet is A1..B3
| A | B |
1| user | password |
2| 1234 | abc |
3| 3433 | def |
require 'rubygems'
require 'watir-webdriver'
require "watir-webdriver/extensions/alerts"
require 'win32ole'
require './xls.rb' # OUR DOWNLOADED EXCEL helper
sSpreadSheet='myExcelFile.xls'
sSheetName='Sheet1'
sRange='A1..B3' #or better still use a range name
myData = {} # Define empty hash table
xlFile = XLS.new(Dir.pwd + '/'+sSpreadSheetName)
myData = xlFile.getRowRecords(sRange,sSheetName)
xlFile.close
# Check the contents
puts ' - Length of Data Set: '+myData.length.to_s
iExcel=0
myData.each do
puts myData[iExcel].fetch('user')
puts myData[iExcel].fetch('password')
iExcel=iExcel+1
end
If you search the group for xls.rb and/or excel you'll find enough topic
help to guide you
**
On Monday, June 18, 2012 12:30:30 PM UTC-5, Harrington wrote:
> Hi iam considering automating a task that is from an web base
> application and a Excel work book . The web base application will
> open in IE and a I want to move data before the two. Is this
> possible to do using ruby on watir ?
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]