18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

decimal issue while working with .xls on Sahi V2 Release 2009-05-21

edited November -1 in Sahi - Open Source
SAHI throws "java.sql.SQLException: [Microsoft][ODBC Excel Driver] 'Sheet1$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long." while reading data from excell in Sahi V2 Release 2009-05-21 but works fine with the code below in sahi_20090217.

Can someone please provide a solution...

Here is my code -
var db = _getDB("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=E:\\sahi_20090521\\Data\\Login.xls","","");
var $XlsData = [];
$XlsData[0] = [];
var $XlsData = db.select("select * from [Sheet1$]");
var $data1 =($XlsData[0]["userName"]);
var $data1 =($XlsData[0]["Password"]);
_setValue(_textbox("userName"), ($XlsData[$i]["userName"]));
_setValue(_textbox("userName"), ($XlsData[$i]["Password"]));

Input of username = 9000 or Mav2009 and input of password = 12345 or password1

When i comment line: var $XlsData = db.select("select * from [Sheet1$]")
SAHI doesnt throw any error but picks up value with .0 added

Comments

  • dpdp Members
    The appended ".0" issue could be resolved by prefixing an apostrophe to the value in the spreadsheet cell. For example, if the value of username is 9000, then enter it as '9000 so that Excell treats this as a text value than a numeric value
  • tried using the solution above, but SAHI reads number added as '9000 in excel as a blank value.
  • dpdp Members
    What do you get when you execute the below code?


    var db = _getDB("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=E:\\sahi_20090521\\Data\\Login.xls","","");

    var $XlsData = db.select("select * from [Sheet1$]");

    _setValue(_textbox("userName"), ($XlsData[0]["userName"]));
Sign In or Register to comment.