Forum Discussion

pradeep_kamatha's avatar
pradeep_kamatha
Contributor
12 years ago

DB data needs to be verified against the output CSV File

Hi,

I would like to compare my DB table data with CSV File data. Should be matched, for this I want to write all the DB data to CSV File and store it in local drive then compare with another CSV which has already DB data.. 



Please help me how to store DB data into Arrays or CSV File.

  • Hi Pradeep,


     


    This script exports data from the DBTable object to an Excel file. You can use it as a template to create your own script to export data to a CSV file.


     

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Pradeep,


     


    This script exports data from the DBTable object to an Excel file. You can use it as a template to create your own script to export data to a CSV file.


     

  • Thanks Tanya..



    I can't copy the files continuosly ..  Do we have a method like clean the excel sheet before go for another Run..



    Regards,

    Pradeep
  • THanks for your suggestion.. I am not ablet o compile it.. Could you please go through below code and suggest me how I need to call..




    function TableToExcel(tableObject, excelFileName)


     


        {


     


          var objExcel = Sys.OleObject("Excel.Application");


     


          objExcel.Visible = false;


     


          objExcel.DisplayAlerts = false;


          objExcel.Worksheets.("Sheet1").Range("A1:W100").ClearContents


          var objWBook = objExcel.Workbooks.Add();


     


          var objWSheet = objWBook.Sheets(1);


     


     


            for (var i = 0; i < tableObject.RowCount; i++)


     


            for (var j = 0; j < tableObject.ColumnCount; j++)


     


              objWSheet.Cells(i+1, j+1) = tableObject.Values(i, j);


     


           


     


          objWBook.SaveAs(excelFileName) ;


         Log.Message("Data has been uploaded to C:\\CAL.xlsx");


     


          objExcel.ActiveWorkbook.Saved = true;


        objExcel.DeleteCustomList()


     


          objExcel.Application.Quit();  


      


        }


     


    function test()


     


        {


     


          TableToExcel(DBTables.AMI_READ_ROUND, "C:\\CAL.xlsx");


     


        }