Forum Discussion
Hi,
What exactly did you mean saying "doesn't work correctly"? Did you receive any kind of error?
I'm defining two DDT drivers, the first one works correctly even if my Excel file is closed and the second one if my file is open it works too but if it is closed, Testcomplete waits for a long time without executing anything as if it is not getting the Data from the Excel sheet.
this is my code:
set xlDriver = DDT.ExcelDriver("C:\Script-Resources\BatchRun\myfile.xls","Sheet1",True) xlDriver.First while not xlDriver.EOF value1= xlDriver.Value("x") value2= UCase(xlDriver.Value("y")) if value1= "Y" then value3 = xlDriver.Value("z") value4= xlDriver.Value("t") If value2= "ENVIRONMENT_SET" Then value5= value2 BuiltIn.ShowMessage( value5) Else If value5="" Then call Basic.myfunction() ExitTest Else set xlDriver1 = DDT.ExcelDriver(C:\Script-Resources\BatchRun\myfile2.xls,"BatchRun",True) xlDriver1.First while not xlDriver1.EOF value6= xlDriver1.Value("xx") if value6= "Y" then value7= xlDriver1.Value("yy") value8= xlDriver1.Value("tt")
- baxatob8 years agoCommunity Hero
In the second case you are passing third parameter as True. This should use ACE Driver instead of ODBC:
1st case: set xlDriver = DDT.ExcelDriver("C:\Script- Resources\BatchRun\myfile.xls","Sheet1",false) 2nd case: set xlDriver1 = DDT.ExcelDriver(C:\Script- Resources\BatchRun\myfile2.xls,"BatchRun",True)
Why you are doing so? Try to change it to False.
- rhsou1238 years agoContributor
it was false for both drivers and just update it to check if it works.
Even with two false it is not working.
- tristaanogre8 years agoEsteemed Contributor
Concerning the ACE driver boolean flag (the third parameter in the DDT.ExcelDriver method). If you have Excel 2007 or later installed, that should be set to true. That is to use the ACE driver instead of the ODBC driver when connecting to an Excel book to access sheets as data tables. Honestly, they should both be set to true if you are Excel 2007 or later or both be set to false if using anything earlier than Excel 2007.
As for having the Excel workbook open while you are using the DDT.ExcelDriver method... that's a no-no with the ACE driver (with the ODBC driver, not so much). This is because the ACE driver actually uses (as I understand it) the Excel data connectivity components of the Excel application. So, with the workbook open, you have effectively, in database terms "locked" the table for reading with an exclusive lock.
Generally speaking, when you are running tests using Excel as a data storage, you should NOT have the Excel workbook open while the tests are running. While the ODBC driver allows it, it's still not a good practice... you could be changing data records while the test is in progress. Close your Excel book, set both properties to "true" to use the ACE driver, and re-run your tests.- rhsou1238 years agoContributor
I'm using Excel 2016 and I changed the third parameter to True. Tm still facing the same problem, Testcomplete waits for a long time without any Execution or it exits after connecting to the first driver !
Related Content
- 7 months agoḼari