Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
4 years ago

Returning values from Excel File

Hi,

 

I am new to TC and trying to access/retrieve different cell values through DDT object.

I have the below code, but the result is empty. My Excel structure is : First column has heading username and second column has heading password, rows have data for both columns

 

//USEUNIT A

function DDTReadExcel()
{
var lines = [];

var data = DDT.ExcelDriver(file, sheet); //file and sheet are getting values from UNIT A
while(!data.EOF())
{
var line = {};
for(var i = 0; i < data.ColumnCount; i++)
{
var colName = data.ColumnName(i);
line[colName] = data.Value(colName);
//Log.Message(line[colName])
}
lines.push(line);
data.Next();
}
return lines;
}

 

..................................................

//USEUNIT C

function abc ()
{

var people = DDTReadExcel();
Log.Message(people[1].First);
}