The DDT.ExcelDriver
method allows auto-detecting the Excel driver with the help of Open Database Connectivity (ODBC) or the Microsoft Access Database Engine (ACE) driver depending on the Excel file format after saving.
To this end, the UseACEDriver
parameter is to be used. If you would not like to have these parameters signified explicitly each time, it is possible to write a wrapper function to do this automatically.
To automatically define the type of the driver, we need to perform the following steps:
DDTExcel
function:function DDTExcel(fileName, sheetName) { var useACE = aqFileSystem.GetFileExtension(fileName) == "xlsx"; return DDT.ExcelDriver(fileName, sheetName, useACE); }
var data = DDTExcel("C:\data.xls", "Sheet1"); var data = DDTExcel("C:\data.xlsx", "Sheet1");
The useACE
parameter of the ExcelDriver
method specifies which exact driver (ODBC or ACE) should be used to access file data.
To automatically define the type of the driver, we have used the simplest method of file-extension analysis. For the files with xls
extension, the ODBC driver is used, while the driver of the type of ACE is utilized for the xlsx
files.
It is possible to use the ACE driver both for the files of the xls
type, and for the xlsx
files as well. The following two examples will handle the task of file recognition equally effectively:
var data = DDT.ExcelDriver("C:\data.xls", "Sheet1", true); var data = DDT.ExcelDriver("C:\data.xlsx", "Sheet1", true);
18.219.228.88