BMD
10 years agoContributor
DDT.ExcelDriver for .xlsx not .xls
Team,
The function below worked until I changed the format from .xls to .xlsx. Now the log returns "
External table is not in the expected format". Is there are way to correct this. I did not think the two Excel formats would cause this?
This is how the function is called:
ReadExcelHeaderFile((PathFileName), "Project", 0);
This is the function
function ReadExcelHeaderFile(PathFileName, TargetText, TargetCell) //Search for column header text in an Excel at a known column number
//Argument (path and filename, text to search for, column number) { DDT.ExcelDriver((PathFileName), "Sheet1"); if ( (TargetText) == (DDT.CurrentDriver.ColumnName(TargetCell)) ) { Log.Message("Found "+(DDT.CurrentDriver.ColumnName(TargetCell))+" in header in column "+(TargetCell)); } else { Log.Warning("DID NOT Find "+(DDT.CurrentDriver.ColumnName(TargetCell))+" in header in column "+(TargetCell)); Project.Variables.FailFlag ++; } // Closes the driver DDT.CloseDriver(DDT.CurrentDriver.Name); }
Thanks for any pointers.
BMD
Hello BMD,
You may need to download the Microsoft Office data connectivity driver to access the newer XLSX format.
2007 Office System Driver: Data Connectivity Components
More details on this in the TestComplete help here:
Using Excel Files as Data Storages
-Dan
You probably need to change
DDT.ExcelDriver((PathFileName), "Sheet1");
to
DDT.ExcelDriver((PathFileName), "Sheet1", true);
in order to use .xlsx instead of .xls.