Forum Discussion

DarkShadows's avatar
DarkShadows
Contributor
6 years ago
Solved

TestComplete_How to read and pass the 2nd row and 3rd column specific value using DDT driver?

Hello team,

Could you please help me to explain how should I read and pass specific cell value by reading it through row and column number. Using below scripts I'm failed to retrieve the specific cell values.

Any guidance on it will be really appreciated

 

Thanking you.

 

function ReadEx()

{

ExcelPath = 'C:\\Stores\\ExWorksheet.xlsx';

Driver = DDT.ExcelDriver(ExcelPath , "Sheet1");

Driver.First(); while (! Driver.EOF())

{

for (i=0; i<5; i++)

{

for (j = 0; j< i;j++)

Log.Message(Driver.Value(i, j));

}

}

Driver.Next();

}

 

  • DDT driver does not return cell values.  Basically, the DDT driver treats the excel sheet as a data table.  You iterate through the rows (That's what Driver.Next does... it takes you to the next row).  The "for" loops are not only not necessary... they won't work.

    Since you want to iterate through every row and grab every column, then within the while loop, you simply need to call Driver.Value(<columnName>) for each column.  

     

    If you want to grab a specific cell value from an excel sheet, your better bet is to call Exce.Application COM object.

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    DDT driver does not return cell values.  Basically, the DDT driver treats the excel sheet as a data table.  You iterate through the rows (That's what Driver.Next does... it takes you to the next row).  The "for" loops are not only not necessary... they won't work.

    Since you want to iterate through every row and grab every column, then within the while loop, you simply need to call Driver.Value(<columnName>) for each column.  

     

    If you want to grab a specific cell value from an excel sheet, your better bet is to call Exce.Application COM object.