Forum Discussion

sarya's avatar
sarya
Frequent Contributor
15 years ago

Excel file automation

Hi ,



I have to verify an excel file ,so can I verify individual cells in the spreadsheet .If cell comparison is possible, what is the kind of  code that needs to be there.Currently my code compared one output file to another sample fiel but if it does not find anything in the output file,it is not able to point out which value is missing. Can the verification be more elaborate?


function ExcelVerify(DataBeginsFromRow,path) {


ExcelVerify(DataBeginsFromRow,path) {

var sheets = ["100", "200", "300"];


for (var i = 0; i <= sheets.length - 1; i++) {


var driver = DDT.ExcelDriver(path, sheets);


var counter = 0;


while (! driver.EOF()) {


if (counter + 1 > DataBeginsFromRow)

{

for (var j = 0; j <= driver.ColumnCount - 1; j++)

{

Log.Message(driver.Value(j))

}

}


driver.Next();

counter++;


}


}


}







function ExcelCompare(file1,file2,sheet)


ExcelCompare(file1,file2,sheet)

{



var TestRecordSet = DDT.ExcelDriver(file1,sheet);


TestRecordSet = .ExcelDriver(file1,sheet);

var BaseRecordSet = DDT.ExcelDriver(file2,sheet);


BaseRecordSet = .ExcelDriver(file2,sheet);

while (! TestRecordSet.EOF() && ! BaseRecordSet.EOF())


(! TestRecordSet.EOF() && ! BaseRecordSet.EOF())

{


for (i = 0; i < DDT.CurrentDriver.ColumnCount; i++)


{


if (!(TestRecordSet.Value(i)== BaseRecordSet.Value(i)))


Log.Warning("The value in column" + TestRecordSet.ColumnName(i) + "does not match the expected value");


}


TestRecordSet.Next(); // Goes to the next record


BaseRecordSet.Next(); // Goes to the next record


}



return true;


;

}



Thanks,

Sumedha


15 Replies