DefinitelyTyped/ts-activex/activex-data-objects-tests.ts
Zev Spitz e0896e285b Rename WIA files; removed VarDate interface (#10081)
* Rename WIA files

* Removed VarDate definition; is now in lib.d.ts
Renamed WIA definition
Added ADO definitions

* Restored VarDate; TS lint fixes

DefinitelyTyped is still using Typescript 1.8 in Travis CI compile
checks.
2016-07-12 23:28:46 -07:00

21 lines
717 B
TypeScript

/// <reference path="activex-data-objects.d.ts" />
//open connection to an Excel file
var pathToExcelFile = 'C:\\path\\to\\excel\\file.xlsx';
var conn = new ActiveXObject('ADODB.Connection');
conn.Provider = 'Microsoft.ACE.OLEDB.12.0';
conn.ConnectionString =
'Data Source="' + pathToExcelFile + '";' +
'Extended Properties="Excel 12.0;HDR=Yes"';
conn.Open();
//create a Command to access the data
var cmd = new ActiveXObject('ADODB.Command');
cmd.CommandText = 'SELECT DISTINCT LastName, CityName FROM [Sheet1$]';
//get a Recordset
var rs = cmd.Execute();
//build a string from the Recordset
var s = rs.GetString(ADODB.StringFormatEnum.adClipString, -1, '\t', '\n', '(NULL)');
rs.Close();
WScript.Echo(s);