mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* 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.
21 lines
717 B
TypeScript
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); |