Data-Connector
Version Info
Minimum Origin Version Required: Origin 2019b
Connect to File
Full Path
void dc_excel_ex()
{
WorksheetPage wp;
wp.Create("origin");
int nErr = wp.DoMethod("DC.Add", "Excel");
if(nErr)
{
out_int("nErr=", nErr);
return;
}
Worksheet wks = wp.Layers(0);
string strURL = GetAppPath(TRUE) + "Samples\Import and Export\United States Energy (1980-2013).xls";
wks.SetProp("DC.Source", strURL);
wks.SetProp("DC.Sel", "Natural Gas");
wks.DoMethod("DC.Import");
}
Relative to Project Path
void dc_csv_ex()
{
string strPath = GetAppPath(TRUE) + "Samples\Data Manipulation\Setting Column Values.opj";
Project.Open(strPath);
WorksheetPage wp;
wp.Create("origin");
int nErr = wp.DoMethod("DC.Add", "CSV");
if(0==nErr) {
Worksheet wks = wp.Layers(0);
string strURL = "..\Import and Export\donations.csv"; //relative to project path
wks.SetProp("DC.Source", strURL);
wks.DoMethod("DC.Import");
}
}
Relative to Common Data Path
void dc_impfilter_ex()
{
string strPath = GetAppPath(TRUE) + "Samples\\";
ChangeCommonDataPath(strPath);
WorksheetPage wp;
wp.Create("origin");
int nErr = wp.DoMethod("DC.Add", "import filter");
if(0==nErr) {
Worksheet wks = wp.Layers(0);
string strURL = "*.\Import and Export\S15-125-03.dat"; //relative to Common Data path
wks.SetProp("DC.Source", strURL);
wks.SetProp("DC.Sel", "VarsFromFileNameAndheader.oif");
wks.DoMethod("DC.Import");
}
}
Connect to Web
void dc_json_ex()
{
WorksheetPage wp;
wp.Create("origin");
int nErr = wp.DoMethod("DC.Add", "JSON");
if(nErr)
{
out_int("nErr=", nErr);
return;
}
Worksheet wks = wp.Layers(0);
string strURL = "https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2018-01-01&endtime=2018-01-23";
wks.SetProp("DC.Source", strURL);
wks.SetProp("DC.Sel", "JSON/features");
wks.DoMethod("DC.Import");
}
void dc_html_ex()
{
WorksheetPage wp;
wp.Create("origin");
int nErr = wp.DoMethod("DC.Add", "HTML");
if(nErr)
{
out_int("nErr=", nErr);
return;
}
Worksheet wks = wp.Layers(0);
string strURL = "https://en.wikipedia.org/wiki/List_of_metropolitan_statistical_areas";
wks.SetProp("DC.Source", strURL);
wks.SetProp("DC.Sel", "Tables/_1");
wks.DoMethod("DC.Import");
}
Connect to Matlab
void dc_matlab_ex()
{
WorksheetPage wp;
wp.Create("origin");
int nErr = wp.DoMethod("DC.Add", "MATLAB");
if(nErr)
{
out_int("nErr=", nErr);
return;
}
Worksheet wks = wp.Layers(0);
string strURL = "\\\poly\Dropbox\TS\File Types\MATLAB\SamplesFromSam\Spectra Data\NIR for Gasoline\GasolineNIRv7.mat";
wks.SetProp("DC.Source", strURL);
wks.SetProp("DC.Sel", "MATLAB/NIR");
wks.DoMethod("DC.Import");
}
Connect to Origin
Worksheet can do partial import
void dc_origin_ex()
{
WorksheetPage wp;
wp.Create("origin");
int nErr = wp.DoMethod("DC.Add", "ORIGIN");
if(nErr)
{
out_int("nErr=", nErr);
return;
}
Worksheet wks = wp.Layers(0);
string strURL = GetAppPath(TRUE) + "Samples\Data Manipulation\Setting Column Values.opj";
wks.SetProp("DC.Source", strURL);
wks.SetProp("DC.Sel", "[Book1]Sample!1-2");//Partial import column 1 & 2
wks.DoMethod("DC.Import");
}
|