Re: [Wtr-general] Reading from excel files (basic)

2007-03-29 Thread Nicola Kennedy
Thanks very much, managed to sort it now.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Reading from excel files (basic)

2007-03-27 Thread sathees
if you are only getting 4 cells, why the array show a long list with nil. your 
are missing something here. Check your code again!
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Reading from excel files (basic)

2007-03-26 Thread sathees
$data = []
$data = worksheet.Range('a1:z1')'text' # The data is in cell a1.
excel'Visible' = false # hide the spreadsheet from view
workbook.close
excel.Quit

# Insert the data read from the spreadsheet into the text field
#$ie.text_field(:name, 'TEST').set $data
$data.length do |x|
ie.goto('http://' + $data[x])
end

$data is not a good idea as the $ stands for global variable. If not needed to 
be global remove them and replace with @ or @@ as your definitions needs.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Reading from excel files (basic)

2007-03-26 Thread Nicola Kennedy
Hi,

Have done this, but am getting error:
 1) Error:
test_recorded(TC_recorded):
NoMethodError: undefined method `length' for nil:NilClass
testnic2.rb:50:in `test_recorded'

Have copied my script again in case I've done something wrong?


 excel = WIN32OLE::new('excel.Application')
workbook = excel.Workbooks.Open('C:\Documents and Settings\kennedyn\My 
Documents\WATIR_RUBY\excel_testdata.xls')
worksheet = workbook.Worksheets(1) #get hold of the first worksheet
worksheet.Select
@mydata = []
@mydata = worksheet.Range('a1:a4')['text'] # The data is in cell a1.
excel['Visible'] = true # hide the spreadsheet from view
workbook.close
excel.Quit

# Insert the data read from the spreadsheet into the text field
#$ie.text_field(:name, 'TEST').set $data

#ie.goto('http://' + @mydata)


# Insert the data read from the spreadsheet into the text field
#$ie.text_field(:name, 'TEST').set $data
@mydata.length do |x|
ie.goto('http://' + @mydata[x])
end

TIA
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Reading from excel files (basic)

2007-03-26 Thread sathees
try this

@mydata = worksheet.Range('a1:a4').value
puts @mydata # to c wether the content is in the array.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Reading from excel files (basic)

2007-03-26 Thread Nicola Kennedy
Hi,

I did this and the logs showed the websites as follows:

www.google.co.uk
www.freeuk.com
www.bbc.co.uk
www.manilow.com
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil

The test then just ends, with no errors, but the test doesn't take me to the 
four websites.
As an aside as well, I don't want it to enter nil as the web address, so is 
there a way once this is fixed, that it knows to stop putting stuff into the 
array when the next cell is empty.

Have pasted script as it stands below



 excel = WIN32OLE::new('excel.Application')
workbook = excel.Workbooks.Open('C:\Documents and Settings\kennedyn\My 
Documents\WATIR_RUBY\excel_testdata2.xls')
worksheet = workbook.Worksheets(1) #get hold of the first worksheet
worksheet.Select
@mydata = []
@mydata = worksheet.Range('a1:z1').value # The data is in cell a1.
puts @mydata # to c wether the content is in the array.
excel['Visible'] = true # hide the spreadsheet from view
workbook.close
excel.Quit

# Insert the data read from the spreadsheet into the text field
#$ie.text_field(:name, 'TEST').set $data

#ie.goto('http://' + @mydata)


# Insert the data read from the spreadsheet into the text field
#$ie.text_field(:name, 'TEST').set $data
@mydata.length do |x|
ie.goto('http://' + @mydata[x])
end

TIA
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Reading from excel files (basic)

2007-03-26 Thread Charley Baker

Hi Nicola, you could try something like this:




excel = WIN32OLE::new('excel.Application')
   workbook = excel.Workbooks.Open('C:\Documents and
Settings\kennedyn\My Documents\WATIR_RUBY\excel


_testdata2.xls')
worksheet = workbook.Worksheets(1) #get hold of the first
worksheet
worksheet.Select
[EMAIL PROTECTED] = []
[EMAIL PROTECTED] = worksheet.Range('a1:z1').value # The data is in cell
a1.
#puts @mydata # to c wether the content is in the array.
excel['Visible'] = true # hide the spreadsheet from view



line = '1'
while val = worksheet.Range(a#{line})['Value']   #pull the value
stored in the cell while it's valid
  ie.goto(val)#use the value
  line.succ!  #update the line number
end

This will only loop through for the first column a(1-end of valid values).
You can expand it to pull an array if you want.

-Charley

   workbook.close

excel.Quit








On 3/26/07, Nicola Kennedy [EMAIL PROTECTED] wrote:


Hi,

I did this and the logs showed the websites as follows:

...
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general