Brilliant, changing spreadsheetdata[:accountnumber] = row.cells(4,57)['value'] to spreadsheetdata[:accountnumber] = row.cells(4,57)['text']
sorted me out, so what is the difference between the two ? thanks for the solution On 5/10/07, Paul Rogers <[EMAIL PROTECTED]> wrote:
your code doesnt show where you create spreadsheetdate but if you use either the text or attribute ( i cant remember which, and dont have excel here ) myval = worksheet.range('a2')['value'] # or ['text'] one of these will do the right thing Paul ----- Original Message ----- *From:* Tunde Jinadu <[EMAIL PROTECTED]> *To:* Wtr-general@rubyforge.org *Sent:* Wednesday, May 09, 2007 3:01 PM *Subject:* [Wtr-general] Watir Data types exported from excel I'm running a script to read data from a spreadsheet using the following script # open the spreadsheet and get the values excel = WIN32OLE::new('excel.Application') # define the type of application to connect too workbook = excel.Workbooks.Open('d:\Smoke_Test2.xls') # spreadsheet location worksheet = workbook.Worksheets(1) #get hold of the second worksheet worksheet.Select #bring it to the front -need sometimes to run macros, not for working with a worksheet from ruby range=worksheet.range("a1", "bw50") # range of spreadsheet #~ excel['Visible'] = false #make visible, set to false to make invisible again. Don't need it to be visible for script to work the value I am picking out of the spreadsheet is a number 11111111 using the following ie.text_field (:id,/AccountNumber/).set(spreadsheetdata[:'accountnumber'].to_i) when the script enters data into the field it attempts to enter data as follows 11111111.0 (decimal place materialises.) I think ruby changes the format of the number 1111111 extracted from the spreadsheet from an integer as specified using .to_i to another format (hence the decimal place being displayed in the form field) How can I ensure the format of the data extracted from excel stays as an integer or text, allowing a leading zero as '01111111' or '11111111' -- The second half of a man's life is made up of nothing but the habits he has acquired during the first half. - Fyodor Dostoevsky ------------------------------ _______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general _______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
-- The second half of a man's life is made up of nothing but the habits he has acquired during the first half. - Fyodor Dostoevsky
_______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general