Forum Discussion

Jessie_li's avatar
Jessie_li
Occasional Contributor
12 years ago

Excel cannot open while DDT.ExcelDriver is opened

Hi,
I got a issue to open excel file while DDT driver is opening, the script is as following. The issue happens only on excel 2007, if you are using excel 2010, everything is fine. Hope anyone could help me to find the reason, thanks in advance.


function test(){
var driver = DDT.ExcelDriver("TestData//test.xlsx","Input-Output",true);
driver.Next();
while(!driver.EOF()){
var filePath = Project.ConfigPath + "\TestData\\" + "test.xlsx";
var excelApp = new ActiveXObject("Excel.Application");
excelApp.DisplayAlerts = false;
var excelWorkBook = excelApp.Workbooks.open(filePath);
driver.Next();
}
DDT.CloseDriver(driver.Name);
}


If test using excel 2007, it will encounter the error:
Excel cannot open the file 'test.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
  • I'm not sure but try this:

    var driver = DDT.ExcelDriver("TestData//test.xlsx","Input-Output");

    ---instead of---

    var driver = DDT.ExcelDriver("TestData//test.xlsx","Input-Output",true);



    When omitted, the UseACEDriver parameter is false by default. It will use a different driver to open the file. To read more about it, open your code, click on .ExcelDriver, and hit F1.



    You have a lot of extra ActiveXObject creation, etc. that you shouldn't need. The driver will take care of all that for you.  All you need to do is use DDT.ExcelDriver() to specify the file and sheet, Driver.Value(n) to get the value from the n column, and DDT.CurrentDriver.Next() to go to the next row. See the code example at the bottom of the .ExcelDriver page for a simple example.