3.7.5.103 Wks.DC

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.

Note:

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

Properties and Methods

Property Access Description
wks.DC.Source$ Read/write
string
Relative path of data source.
wks.DC.Path$ Read/Write
string
Absolute file path of data source. Return empty if not File path (the data source is from web for example).
wks.DC.Sel$ Read/Write
string
Specify the selection of sheets/table inside the data source. Since CSV file has only one sheet, it doesn't have selection.
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.Valid Read/write
numeric
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.

wks.DC.Allow() Read/write
numeric
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:
wks.DC.allow(2)=;
It will return 1 if worksheet is the proper type and File Import Info if present has been removed.

wks.DC.IMPORT() Read/write
numeric
Import data into current sheet, without opening the Import Options dialog.
wks.DC.SType Read/write
numeric
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.RESET() Read/write
numeric
Clear imported data. The connection will remain.
wks.dc.optn$ Read/write
string
Get or set connecotr settings as a string. Supported only for CSV, Excel etc connector types using its own GetN dialog.

Examples

//This example shows how to import a CSV file by Data Connector
newbook;
wbook.dc.add("CSV");
wks.dc.source$=System.path.program$+"Samples\Batch Processing\T275K.csv";
wks.dc.import();
//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(); };