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 Only Check if the workbook allows connections to multiple data sources.

Returns 1 for yes, and 0 for no

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[,1]) 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.

Note that in the case of some complex file structures (NetCDF, HDF), import times may be significantly reduced by not showing the Data Navigator pane. To prevent the Navigator pane from being added on import, add "1" as an argument:

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.newsheet(sheet$) Connect to another sheet.
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);

This example uses the Origin Connector to import data from another Origin project by running a query (information on the SQL-like query language supported by the Origin Connector can be found here).

// Origin project file location:
string path$ = "C:\temp\mydata.opju";
// Create new workbook in current project
// Connect to the desired Origin project using the Origin Data Connector
wks.dc.source$ = path$;
// Specify query string to pull all X columns that have long name of "alpha"
wks.dc.sel$=Select Column from Project where (Column_LName like "alpha" AND Column_Type = X);
//This example uses the NetCDF Connector to do partial import of web-stored multi-dimensional data in a .nc file
newbook mat:=1;
// import z=1 to end, read 1 skip 11; lon shift, lat flip, formula v*0.0393701

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";

This example can import Excel file with two sheets and setting headings

string fname$=system.path.program$ + "Samples\Import and Export\United States Energy (1980-2013).xls";
wks.dc.source$ = fname$;
Tree tr1 = wks.dc.Optn$;
tr1.Settings.mainheader = 2;
wks.dc.sel$ = "Oil";
//now connect to another sheet named "Coal"

See Also

Wks, Wks.DC