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.

Unable to read an integer valus from Excel sheets

devdev Members
edited November -1 in Sahi - Open Source
Hi All,

I am new to this tools and was having following issues, please help me to go through.


Here are the details,

Excel file name = DataSummary.xls.
Location = D:

Xls file contained following column with integer values

Value
12

sample code
var db = _getDB("sun.jdbc.odbc.JdbcOdbcDriver",
"jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=D:\\DataSummary.xls;readOnly=false",
"",
"");
$rs = db.select("select * from [Sheet1$]");

_assertEqual("12", $rs[0]["Value"]); //Following line got fail since system display "$rs[0]["Value"]" as "null".
_assertEqual(12, parseInt($rs[0]["Value"])); //Following line got fail since system display "$rs[0]["Value"]" as "NaN".

Comments

  • devdev Members
    Can read int value same as string values when you change the format of the integer cells in excel sheet.

    1. Right click on cell which contain integer value
    2. Select format cell
    3. Select category as text and OK.

    Now below code should get pass
    _assertEqual(12, ($rs[0]["Value"]));
  • SumitraSumitra Members
    Hi dev,

    Please check if the path to your xls file is correct. Also, check if the data is available in the right sheet. In this case, the sheet being selected is "Sheet1".

    Once this is done, the following script should work with your excel file

    DataSummary.xls
    Value
    12
    

    Sahi script:
    var db = _getDB("sun.jdbc.odbc.JdbcOdbcDriver",
            "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=D:\\DataSummary.xls;readOnly=false",
            "",
            "");
    
    $rs = db.select("select * from [Sheet1$]");
    _assertEqual(12, $rs[0]["Value"]); 
    _assertEqual(12, parseInt($rs[0]["Value"]));
    


    Regards
    Sumitra
  • narayannarayan Administrators
    Hi Sumitra,

    Dev has already mentioned that he has found the solution. Closing this.

    Regards,
    Narayan
This discussion has been closed.