📄 page.h
字号:
// in the project.
void run_Layers()
{
GraphPage gp("Graph1");
string strLayerName = "ABC";
GraphLayer gl = gp.Layers(strLayerName);
if (gl.IsValid())
out_str("The layer exists.");
else
out_str("The layer does not exist.");
}
*/
GraphLayer Layers(LPCSTR lpcszName);
};
/** >Internal Origin Objects
The LayoutPage class provides methods and properties common to all internal Origin
layout pages (windows). The Project class contains a collection of LayoutPage objects.
An Origin C LayoutPage object is a wrapper object that is a reference to an internal
Origin layout page object. Origin C wrapper objects do not actually exist in Origin
and merely refer to the internal Origin object. Consequently, multiple Origin C wrapper
objects can refer to the same internal Origin object. The LayoutPage class is derived
from the Page, PageBase, and OriginObject classes from which it inherits methods and
properties.
Example:
// Assumes Layout1 window with at least one Graph Object exists in Origin
LayoutPage lpg;
Layout lo;
GraphObject go;
lpg = Project.LayoutPages("Layout1"); // Get Layout1 page from LayoutPages collection
if(lpg) // If lpg IsValid...
{
lo = (Layout) lpg.Layers(0); // Get Layout1 Layer from Layers collection
if(lo) // If lo IsValid...
{
go = lo.GraphObjects(0); // Get first GraphObject in Layout Layer
if(go) // If go IsValid...
{
printf("Name of first GraphObject is %s\n", go.GetName() );
}
}
}
*/
class LayoutPage : public Page
{
public:
/**
Construct a LayoutPage object using the name of an existing page.
Parameters:
lpcszName = The name of an existing page.
Example:
LayoutPage lp;
lp.Create("origin.otp");
if( lp.IsValid() )
{
LayoutPage lp2(lp.GetName());
if( lp2.IsValid() )
printf("lp and lp2 are both attached to '%s'\n", lp2.GetName());
}
SeeAlso:
Page::Create
*/
LayoutPage(LPCTSTR lpcszName);
/**
Construct a LayoutPage object using an existing LayoutPage object.
Parameters:
page = An existing LayoutPage object.
Example:
LayoutPage lp;
lp.Create("origin.otp");
if( lp.IsValid() )
{
LayoutPage lp2(lp);
if( lp2.IsValid() )
printf("lp and lp2 are both attached to '%s'\n", lp2.GetName());
}
SeeAlso:
Page::Create
*/
LayoutPage(PageBase &page);
};
/** >Internal Origin Objects
The WorksheetPage class provides methods and properties common to all internal Origin
worksheet pages (windows). The Project class contains a collection of WorksheetPage
objects. An Origin C WorksheetPage object is a wrapper object that is a reference to
an internal Origin worksheet page object. Origin C wrapper objects do not actually exist
in Origin and merely refer to the internal Origin object. Consequently, multiple Origin
C wrapper objects can refer to the same internal Origin object. The WorksheetPage class
is derived from the Page, PageBase, and OriginObject classes from which it inherits
methods and properties.
Example:
// Assumes Data1 window with at least one Column exists in Origin
WorksheetPage wp;
Worksheet wks;
Column col;
wp = Project.WorksheetPages("Data1"); // Get Data1 page from WorksheetPages collection
if(wp) // If wp IsValid...
{
wks = (Worksheet) wp.Layers(0); // Get Worksheet from Layers collection
if(wks) // If wks IsValid...
{
col = wks.Columns(0); // Get first Column in Worksheet
if(col) // If col IsValid...
{
Dataset ds(col); // Create Dataset object and attach to column
if(ds) // If ds IsValid...
{
ds.SetSize(10); // Set size of data set
for(int ii = 0; ii < 10; ii++ )
ds[ii]=2*ii+5; // Fill data set/column with values
}
}
}
}
*/
class WorksheetPage : public Page
{
public:
/**
Construct a WorksheetPage object using the name of an existing page.
Parameters:
lpcszName = The name of an existing page.
Example:
WorksheetPage wp;
wp.Create("origin.otw");
if( wp.IsValid() )
{
WorksheetPage wp2(wp.GetName());
if( wp2.IsValid() )
printf("wp and wp2 are both attached to '%s'\n", wp2.GetName());
}
SeeAlso:
Page::Create
*/
WorksheetPage(LPCTSTR lpcszName);
/**
Construct a WorksheetPage object using the name of an existing page.
Parameters:
page = A reference to an existing page.
Example:
WorksheetPage wp;
wp.Create("origin.otw");
if( wp.IsValid() )
{
WorksheetPage wp2(wp);
if( wp2.IsValid() )
printf("wp and wp2 are both attached to '%s'\n", wp2.GetName());
}
SeeAlso:
Page::Create
*/
WorksheetPage(PageBase &page);
/**
It opens an .XLS file lpcszWorkbookFile as either an Excel workbook or as Origin worksheet.
Parameters:
lpcszWorkbookFile=pathname of the .XLS file.
lpcszSheetName=the name of the Excel sheet inside the workbook to open.
If NULL, it opens the workbook as Excel.
If not NULL, it opens only the sheet with this name as Origin worksheet
(other sheets are ignored).
Return:
TRUE if success, otherwise FALSE.
Example:
void test_OpenExcel(string strWorkbookPathname)
{
WorksheetPage wpg;
BOOL bOK = wpg.OpenExcel(strWorkbookPathname, "Sheet2");
out_int("OK = ", bOK);
if (!wpg)
{
out_str("Invalid page!");
}
out_str(wpg.GetName());
}
*/
BOOL OpenExcel(LPCSTR lpcszWorkbookFile, LPCSTR lpcszSheetName = NULL);
/**
It opens an .XLS file lpcszWorkbookFile as an Origin worksheet.
Parameters:
lpcszWorkbookFile=pathname of the .XLS file.
nSheetIndex=the index of the Excel sheet to open as Origin worksheet (other sheets are ignored).
If negative, it opens only the active ("top") sheet.
Return:
TRUE if success, otherwise FALSE.
Example:
void test_OpenExcel_2(string strWorkbookPathname)
{
WorksheetPage wpg;
BOOL bOK = wpg.OpenExcel(strWorkbookPathname, -1);
out_int("OK = ", bOK);
if (!wpg)
{
out_str("Invalid page!");
}
out_str(wpg.GetName());
}
*/
BOOL OpenExcel(LPCSTR lpcszWorkbookFile, int nSheetIndex);
/**
It connects to the Excel sheet with the name lpcszSheetName and makes sure that there are at least
nColsNeeded columns in the underlying layer object.
Parameters:
lpcszSheetName=the name of the sheet to connect.
nColsNeeded=[optional] specifies the minumum number of the underlying Origin columns to create
(the method will automatically create at least as many columns as there are data in
Excel sheet)
Return:
TRUE if success, otherwise FALSE.
Example:
// For this example, to run, a worbook with the name "Book1" must already exist
// in the current project and have at least three sheets.
void ggg()
{
WorksheetPage wpg("Book1");
if (!wpg)
{
out_str("Invalid page!");
return;
}
string strSheet = "Sheet2";
BOOL bOK = wpg.ExcelSheet(strSheet, 25);
out_int("OK = ", bOK);
Worksheet wks = wpg.Layers(strSheet);
if (!wks)
{
out_str("Invalid sheet!");
return;
}
Column col = wks.Columns(23);
if (!col)
{
out_str("Invalid column!");
return;
}
Dataset ds(col);
if (!ds)
{
out_str("Invalid datasset!");
return;
}
ds.SetSize(100);
ds[3] = 765.234;
}
*/
BOOL ExcelSheet(LPCSTR lpcszSheetName, int nColsNeeded = 0);
/**
It connects to the Excel sheet with index nSheetNumber and makes sure that there are at least
nColsNeeded columns in the underlying layer object.
Parameters:
nSheetNumber=the (0-offset) index of the sheet to connect.
nColsNeeded=[optional] specifies the minumum number of the underlying Origin columns to create
(the method will automatically create at least as many columns as there are data in
Excel sheet)
Return:
the name of the sheet if success, otherwise empty string.
Example:
// For this example, to run, a worbook with the name "Book1" must already exist
// in the current project and have the sheet with the name "Sheet2".
void ggg()
{
WorksheetPage wpg("Book1");
if (!wpg)
{
out_str("Invalid page!");
return;
}
string strSheet;
// connect to the third sheet and ensure that there are at least 25 columns.
strSheet = wpg.ExcelSheet(2, 25);
out_str(strSheet);
Worksheet wks = wpg.Layers(strSheet);
if (!wks)
{
out_str("Invalid sheet!");
return;
}
// The 24th column
Column col = wks.Columns(23);
if (!col)
{
out_str("Invalid column!");
return;
}
// The dataset attached to this column:
Dataset ds(col);
if (!ds)
{
out_str("Invalid datasset!");
return;
}
// Set its size:
ds.SetSize(100);
// Set one value:
ds[3] = 765.234;
}
*/
string ExcelSheet(int nSheetNumber, int nColsNeeded = 0);
};
/** >Internal Origin Objects
The Note class provides methods and properties common to all internal Origin Note
pages (windows). The Project class contains a collection of Note objects. An Origin
C Note object is a wrapper object that is a reference to an internal Origin Note
page. Origin C wrapper objects do not actually exist in Origin and merely refer to
the internal Origin object. Consequently, multiple Origin C wrapper objects can refer
to the same internal Origin object. The Note class is derived from the PageBase and
OriginObject classes from which it inherits methods and properties.
Example:
// Assumes Notes window exists in Origin
Note no;
no = Project.Notes("Notes"); // Get Notes page from Notes collection
if(no) // If no IsValid...
{
no.Rename("MyNotes"); // Rename Notes window to MyNotes
}
*/
class Note : public PageBase
{
public:
/**
Construct a Note object using the name of an existing page.
Parameters:
lpcszName = The name of an existing page.
Example:
LT_execute("win -n n MyNotes;");
Note note("MyNotes");
if( note.IsValid() )
{
Note note2(note.GetName());
if( note2.IsValid() )
printf("note and note2 are both attached to '%s'\n", note2.GetName());
}
SeeAlso:
Page::Create
*/
Note(LPCTSTR lpcszName);
/**
Construct a Note object using an existing page object.
Parameters:
page = An existing page object.
Example:
LT_execute("win -n n MyNotes;");
Note note("MyNotes");
if( note.IsValid() )
{
Note note2(note);
if( note2.IsValid() )
printf("note and note2 are both attached to '%s'\n", note2.GetName());
}
SeeAlso:
Page::Create
*/
Note(PageBase &page);
/**
Creates either a new empty Notes (page) window, or a new Notes
window with the contents of a sepcified text file.
Parameters:
nOption = (optional) creating options. Possible values are:
CREATE_VISIBLE - creates a visible Notes page (window)
CREATE_HIDDEN - creates a hidden Notes page
lpcszFilePathName = (optional) the full pathname of the text file
to load into the new page. If NULL, an empty
page is created.
Returns:
TRUE for success, otherwise FALSE.
Example:
void run_this()
{
Note pg;
// Create a new empty Notes window:
if (pg.Create())
{
printf("The name of the new Notes page is %s\n", pg.GetName());
}
else
out_str("Creating a Notes page failed!");
}
*/
BOOL Create(int nOption = CREATE_VISIBLE, LPCSTR lpcszFilePathName = NULL);
/**
This data member is a string containing the notes text.
Example:
LT_execute("win -n n MyNotes;");
Note note("MyNotes");
note.Text = "These are my notes.";
printf("MyNotes contains: %s\n", note.Text);
*/
string Text;
};
#endif //_PAGE_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -