The wbk.DC object has properties and methods related to the Data Connector attached to the workbook. The workbook object can be referred to using either "wbook" or "wbk".


Property Access Description
wbk.DC.mfiles Read/write
Check if the workbook is multiple connected.
wbk.DC.nConns Read Only Returns the number of connected sheets
wbk.DC.OCFiles$ Read Only Returns the relative path of the connector cpp file to the Apps root folder. To construct the full OC file path, use


wbk.DC.type$ Read Only Returns the connector type, CSV_Connector or JSON_Connector. This string can be used in wbk.DC.Add


Method Description
wbk.DC.add(file_type) Add Data Connector of file_type...

... where file_type is the name of the Connector (generally, just the name of the Connector, enclosed by double-quotes if there is a space in the name -- e.g. wbook.DC.add("Import Filter")). If in doubt, use the name of the Connector as it appears on the Connectors tab of the Apps Gallery (minus the word "Connector") and enclose file_type in double-quotes.

wbk.DC.import(nn) Import data:

nn = 0 or not specify: import all sheets in the workbook without opening the select... menu,
nn = 1: only import data for the active sheet. It will open Select... menu and then do the import.

wbk.DC.remove(nn) Remove data connector.

nn = 0: Default value when nn is not specified. Remove data connector object from the current workbook, and remove edit protection from all destination sheets in this workbook.
nn = 1: Disconnect data source from the current worksheet and remove its edit protection.
nn = 2: Remove only eidt protection from the current worksheet, but connection will be kept.


Below codes import a HTML table on a wiki webpage to Origin worksheet.


The following example shows how to import an Excel file by Data Connector.

wks.dc.source$=System.path.program$+"Samples\Import and Export\United States Energy (1980-2013).xls";
wks.dc.sel$="Natural Gas";
//set column label rows
worksheet -s 0 1 0 1; 
wks.setaslabel(C, -1, 0, 0);
wks.setaslabel(L, -1, 0, 0);
wks.setaslabel(U, -1, 0, 0);

The following example shows how to specify an import filter in the same folder as your data file.

wbook.dc.add("Import Filter");
wks.dc.source$="C:\2016\Samples\Import and Export\S15-125-03.dat"; // connect to .dat file
wks.dc.sel$="test1.oif"; //use import filter "test1.oif" in the data folder - see Note

Note: You can refer to an import filter saved to UFF\Filters using the %Y string register as in, for example, wks.dc.sel$="%YFilters\test1.oif";

See Also

Wks, Wks.DC