Create a new page using the supplied template. Supports both *.otw, *.otp as well as *.ogg, *.ogw files.
BOOL Create( LPCSTR lpcszTemplate = NULL, int iOption = CREATE_DEFAULT_OPTIONS )
Returns TRUE for success and FALSE for failure.
EX1
//Create a new workbook void Page_Create_ex1() { WorksheetPage wksPg; wksPg.Create("Origin"); }
EX2
int Page_Create_ex2(string strTemplateName = "Origin", BOOL bNoDefaultTemplate = TRUE) { DWORD dwCntrl = CREATE_VISIBLE; if( bNoDefaultTemplate ) dwCntrl |= CREATE_NO_DEFAULT_TEMPLATE; GraphPage gp; if( gp.Create(strTemplateName, dwCntrl) ) { printf("Created a graph named %s\n", gp.GetName()); if( !bNoDefaultTemplate && !strTemplateName.IsEmpty() ) printf("Not sure if specified template %s is used, it may be missing and default was substituded\n", strTemplateName); } else printf("Template %s not found, can not create graph page\n", strTemplateName); return 0; }
EX3
//This example loads an OGW file from the samples folder and set the newly //loaded page's short name. If you repeated run load_ogw, you will see the //new page name will start to enumerate as Test1, Test2 etc. void Page_Create_ex3(BOOL bHideIt = false, string strNewName="Test") { string strPath = GetAppPath(true); strPath += "Samples\Curve Fitting\Single Peak Fit.ogw"; WorksheetPage page; page.Create(strPath, CREATE_HIDDEN); printf("%s\n", strPath); if(!page) { out_str("failed to be loaded"); return; } page.Rename(strNewName); printf("is loaded, new Page Name is %s\n", page.GetName()); if(!bHideIt) page.SetShow(); }
EX3
// use CREATE_EMPTY to create a page without 1st default layer void Page_Create_ex3() { WorksheetPage page; page.Create(NULL, CREATE_EMPTY); printf("Page Name is %s\n", page.GetName()); if(0 == page.Layers.Count()) { page.AddLayer("Test"); int index = 0; foreach(Layer lay in page.Layers) { printf("layer %d named %s\n", index, lay.GetName()); index++; } } else printf("Error, fail to create empty workbook\n"); page.SetShow(); }
Create a new page using the supplied template and attach it to the Origin C object. The Create method should only be called from derived classes such as GraphPage, MatrixPage, WorksheetPage, and LayoutPage. A worksheet page created without a template will not have columns. A matrix page created without a template will have no MatrixObject. Creating a page without specifying a template is faster than when creating one from a template. Code to add needed columns and MatrixObjects can be subsequently executed.
PageBase::PageBase, Page::Page
origin.h