Data Connector added to a worksheet are handled as objects in Origin. The column attributes can be accessed and changed using the properties in the table below.


For workbook level controls of Data Connector, please refer to Wbk object.

Properties and Methods

Property Access Description
wks.DC.Allow() Read/write
Check if the worksheet is used as the destination of a Data Connector:

0 = false,
1 = true,
2 = clean up existing File Import information. If an analysis template imported data with import X-Function in the first place and uses Data Connector to import data later (this may be the case if the template was made in some old version like Origin2019 and reused in newer version like Origin2020b), set Allow to 2 to clear old import info saved in the worksheet:
It will return 1 if worksheet is the proper type and File Import Info if present has been removed.

wks.DC.auto Read/write
Set/Get auto import status:

0 = none,
1 = auto import when project open,
2 = auto import on change
3 = auto import whem changed project open

wks.DC.Flags Read/write
Append data rows in imported file to active worksheet. As of Origin 2021, for Data Connector = Text/CSV only:

0 = (default)) Do not append
256 = append data rows to current sheet on import

wks.DC.Ignore Read/Write
Ignore Data Connector icon. 0 = Data Connector icon is usable, 1 = Data Connector icon is neither selectable nor usable.
wks.DC.Import() Read/write
Import data into current sheet, without opening the Import Options dialog.
wks.dc.optn$ Read/write
Get or set connector settings as a string. Supported only for CSV, Excel etc connector types using its own GetN dialog.
wks.DC.Path$ Read/Write
Absolute path of Connector Data Source, both for local files and for web data as long as the local cache has not expired or been cleared (see @CFDT and delete -web).
wks.DC.Reset() Read/write
Clear imported data. The connection will remain.
wks.DC.Sel$ Read/Write
Specify the selection of sheets/table inside the data source. Use for file formats such as NetCDF or TDMS. Does not apply to formats such as CSV that import into a single sheet. See Examples below.
wks.DC.Source$ Read/write
Relative path of data source.
wks.DC.Sstatus Read Only Source Status:

0 = not dirty
1 = not imported yet
2 = imported but data is cleared, either by Clear Worskheet, or when open from OPJU
3 = dirty, outside file is newer
4 = web content, maybe dirty

wks.DC.SType Read/write
Data source type. It can be

0 = absolute file path, this is the only value that is read-write
1 = project relative file path
2 = common data relative file path
3 = web

wks.DC.Valid Read/write
Check the status of Data Connector added to the worksheet:

0 = has no Data Connector,
2 = worksheet has not been used as destination by any Data Connector,
3 = worksheet is the destination of a Data Connector. You can then use "wks.DC.Source$" to check its data source.
4 = Data Connector has an invalid data source.
5 = source changed.


//This example shows how to import a CSV file by Data Connector
wks.dc.source$=System.path.program$+"Samples\Batch Processing\T275K.csv";
//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
//Import data to all DC-containing books in the Project Explorer (PE) folder
doc -ef LBC { wks.dc.import(); };
//Import data to all DC-containing books in the entire project (all PE folders)
doc -e LBC { wks.dc.import(); };
// This example imports data from another Origin project by running a query, using the Origin Connector
// 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);

Note: information on the SQL-like query language supported by the Origin Connector can be found here.

// import a “*.pil” file by specifying the main header ending text.
String fname$ = “C:\Downloads\MyFiles\pilFiles\testfile-20201204_151244.pil”;
dlgfile group:="*.pil";
wks.dc.source$ = fname$;
Tree tr=wks.dc.optn$;
tr.settings.mainheader = 0; // Main header lines: -1=Auto, otherwise number of lines
tr.settings.endmh$=">END OF HEADER";
tr.settings.heading = 1; // Data has column name: 0=No, 1=Yes
tr.settings.unit = 0; // Data has units: 0=No, 1=Yes
tr.settings.comment1=0;//no comment line