Hi,
I wrote a script in DDT to read rows and columns from excel sheet but it is displaying only two even after my sheet having more than 2 rows.:-
var RecNo;
// Posts data to the l...
Thanks for the reply, Naveenks. As tristaanogre mentioned, it's worth adding your excel file here (or at least a sample to demonstrate the data structure) with the image of the log you get.
It would be helpful to see the Excel file you're using.
Also, your for loop in ProcessData doesn't have any braces around the code to be executed. The way it looks now, it will only get the first column and that's all.
Finally, your increment of the record number needs to be inside the while loop, not the for loop, so it actually tracks the number of records.
I've attached my Excel file and here's the slightly modified code
var RecNo;
// Posts data to the log (helper routine)
function ProcessData(){
var i;
for(i = 0; i < DDT.CurrentDriver.ColumnCount; i++){
Log.Message(DDT.CurrentDriver.ColumnName(i) + ": " + aqConvert.VarToStr(DDT.CurrentDriver.Value(i)));
Log.PopLogFolder();
}
}
// Creates the driver (main routine)
function TestDriver(){
var Driver;
Driver = DDT.ExcelDriver("C:\\Temp\\Test.xls", "Test", true);
// Iterates through records
RecNo = 0;
while (!Driver.EOF()){
ProcessData(); // Processes data
Driver.Next(); // Goes to the next record
RecNo = RecNo + 1;
}
// Closes the driver
DDT.CloseDriver(Driver.Name);
}
Here's what the log looks like
So, as you can see, on principle, your code works. But it needed a bit of refinement to actually do what you wanted it to do.