Forum Discussion

murugans1011's avatar
murugans1011
Regular Contributor
11 years ago

DDT Help

While performing DDT using Excel 'DDT.CurrentDriver.Next' focus next row in excel.is there anyway tat we can set focus to the particular row?

  • function excel2array()


    {


      var excel = DDT.ExcelDriver("C:\\data.xls", "Sheet1");


      


      var data = []; // array to store all rows


      while(!excel.EOF())


      {


        var row = []; // array for storing data from a single row


        for(var i = 0; i < excel.ColumnCount; i++)


        {


          row.push(excel.Value(i));


        }


        data.push(row);


        excel.Next();


      }


      DDT.CloseDriver(excel.Name);


    }



    At the end, the data array will contain all data from the Excel sheet. To access a particular cell:

    data[0][1] - contains value from row 0, column 1, etc.

7 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor

    function excel2array()


    {


      var excel = DDT.ExcelDriver("C:\\data.xls", "Sheet1");


      


      var data = []; // array to store all rows


      while(!excel.EOF())


      {


        var row = []; // array for storing data from a single row


        for(var i = 0; i < excel.ColumnCount; i++)


        {


          row.push(excel.Value(i));


        }


        data.push(row);


        excel.Next();


      }


      DDT.CloseDriver(excel.Name);


    }



    At the end, the data array will contain all data from the Excel sheet. To access a particular cell:

    data[0][1] - contains value from row 0, column 1, etc.

  • karkadil's avatar
    karkadil
    Valued Contributor
    No, but you can read the whole content of the file to an array and then access any row using this array.
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Wil u plz give some source code or link to store excel content to array
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    hi i m using vbscript. i just converted source into vbscript! .getting errror at line data=Array(row)
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    i can able to read data from the excel(see the attached screenshot) .dont kw how to store it in array