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.

Issue exporting data into excel sheet.

Sunny BoySunny Boy Members
edited November -1 in Sahi - Open Source
Hi Sumitra,

i am inserting the value into excel sheet using the above code but i am not able to instert the data is not updating into Excel sheet, please see the my code below please help me out.


var ExObj=_getDB("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=D:\\Sahi Practice\\InputData\\Update_SampleData.xls;readOnly=false", " ", " ");



$strGetval = ExObj.select("select * from [Sheet1$]");

var $strUpdateFirstNumber = parseInt($strGetval[0]["First_Number"]);

_alert($strUpdateFirstNumber);


var $mcode="InsertValue";


ExObj.update("INSERT INTO [Sheet1$] (First_Number) VALUES('"+ $mcode +"')");



$strGetval = ExObj.select("select * from [Sheet1$]");

var $strUpdateFirstNumber = parseInt($strGetval[0]["First_Number"]);

_alert($strUpdateFirstNumber);


and in console i am not getting any error.

Regards,
Sandeep S s

Comments

  • Hi Sandeep,

    Could you please let me know if you want to insert whole table contents into the Excel sheet? If so kindly check the code which i have given.

    If you want to insert a single value from the table then you can use _getText() API and update it into the excel sheet.

    Could you please post how your table looks like?

    Regards
    Sumitra
  • Hi Sumitra,

    Please find the below table here i want to insert only one value to First_Number = 1000 where Action = Multi.

    First_Number Second_Number Action Total
    1000 20 Add 30
    20 10 Sub 10
    10 10 Multi 100
    100 20 Div 5


    please help me out how can i do this.

    Thanks in Advance.


    Regards,
    Sandeep S S
  • Hi Sandeep,

    If the excel sheet is :

    First_Number Second_Number Action Total
    1000 20 Add 30
    20 10 Sub 10
    10 10 Multi 100
    100 20 Div 5

    Now if you want to insert First_Number = 1000 where Action = Multi then use the below code:
    var db = _getDB("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=D:\\trial.xls;readOnly=false","","");
    $rs = db.select("select * from [Sheet1$]");
    db.update("update [Sheet1$] set First_Number=1000 where Action='Multi'");
    

    Check if this solves your issue.

    Regards
    Sumitra
  • Thank you So much Sumitra... this worked...
    you.. Sahi team guys are really genius...Hatts off to you.. Thanku so much...
  • Hi sunny,

    Thanks for the compliments

    Regards
    Sumitra
This discussion has been closed.