I would make your sheet as like below,
ItemNum |
Related PIN |
5546 |
556445 |
5546 |
5564456 |
5546 |
5564457 |
5546 |
5564458 |
5578 |
778665 |
5578 |
778666 |
5589 |
998989 |
5589 |
998988 |
5589 |
889989 |
And using below Excel operations to loop thru for particular item number.
function test(){
var excelFileName = "D:\\Automation\\Scripts\\WorkingScripts\\Automation_Project\\TestData.xls"
var excelSheetName = "Sheet1";
var ItemNumber = 5588;
var columnToFilter = "ItemNumber"
fn_ExcelUsingADODB_test(excelFileName,excelSheetName,columnToFilter,ItemNumber);
}
function fn_ExcelUsingADODB_test(excelFileName,excelSheetName,columnToFilter,columnvalue)
{
var ctExcelProvider64 = "Microsoft.ACE.OLEDB.12.0",ctExcelProvider32 = "Microsoft.Jet.OLEDB.4.0";
var excelConnection = new Sys.OleObject("ADODB.Connection");
var str_Connection = "Provider=" + (is64BitClient() ? ctExcelProvider64 : ctExcelProvider32) + ";Data Source = " + excelFileName + ";Persist Security Info=False;Extended Properties=Excel 8.0;"
excelConnection.Open(str_Connection);
var excel_recordSet = new Sys.OleObject("ADODB.Recordset");
var excelQuery = "select * from [" + excelSheetName + "$] where " + columnToFilter + " = '" + columnvalue + "'" ;
excel_recordSet.Open(excelQuery, excelConnection);
if(!excel_recordSet.bof)
{
excel_recordSet.MoveFirst()
while(!excel_recordSet.eof)
{
for(var i=0; i!= excel_recordSet.fields.count; ++i)
{
Log.Message(excel_recordSet.fields.Item(i).name);
//do your stuff here
}
}
}
excel_recordSet.Close();
excelConnection.Close();
}
function is64BitClient()
{
var tcprocess = Sys.WaitProcess("Test*te", 0);
if(tcprocess.Exists)
{
if(tcprocess.ProcessType == "x64")
{
return true;
}
else if(tcprocess.ProcessType == "x86")
{
return false;
}
else
{
throw "Not able to grab the process type";
}
}
throw "Not able to find the TestComplete/TestExecute process";
}