Hi Qiang,
You could use the code pasted below as a starting point - this code assumes you have version 7 with SR3 (or later) patch.
The code brings up file dialog for user to pick file - this can be replaced by passing file name to the function and then using the file name directly without bringing up dialog. It then uses the worksheet ImportASCII method to read in the file. In this example, the wks is created using a standard template. You can customize a template to set your own ASCII import options (such as how many header lines to skip etc) and then use your custom template instead. The code then creates one simple graph with one layer, and plots all Y datasets into that layer.
Easwar
OriginLab.
void test()
{
Worksheet wks; // create a new worksheet
wks.Create("Origin.OTW"); // use standard Origin wks template
string strFile = GetOpenBox("*.dat"); // bring up file dialog - replace with filename if known
wks.ImportASCII(strFile); // import file into wks
GraphPage grpg; // create a new graph window
grpg.Create("Origin.OTP"); // use standard Origin graph template
GraphLayer grly(grpg.GetName()); // declare graph layer
foreach(Column col in wks.Columns) // loop thru all columns of wks
{
if(OKDATAOBJ_DESIGNATION_Y == col.GetType()) // if it is a Y column...
{
Curve crv(wks, col.GetIndex()); // declare curve using column
grly.AddPlot(crv, IDM_PLOT_LINE); // plot curve in graph layer
}
}
grly.GroupPlots(0); // group all plots in layer
grly.Rescale(); // rescale layer
}