2.1.7 CreatePage
Description
The CreatePage method creates an Origin page of the specified type, such as a worksheet page or graph page.
Syntax
VB: Function CreatePage(Type As ByVal Integer, [ Name As ByVal Object ], [ templateName As ByVal Object ], [ option As ByVal Object ] ) As String
C++: LPCSTR CreatePage(int Type, _variant_t Name, _variant_t templateName, _variant_t option )
C#: string CreatePage(int Type, var Name, var templateName, var option )
Parameters
- Type
- Type of Origin page to be created.
1: Matrix, 2: Worksheet, 3: Graph, 4: Layout, 5: Notes
- Name
- Name to be assigned to the page that is created. If not specified, Origin assigns page name.
- templateName
- Name of the template to be used for creating the page, defaults to no template being used. Note: Creating a worksheet without a template will result in a worksheet with no columns.
- option
- --
Return
A string containing the name of the page created.
Remark
You can also use the Add method in the various page collections to create a new page. This method has the additional option for giving the name of the page.
Examples
VB
Dim oApp As Origin.ApplicationSI
Set oApp = GetObject("", "Origin.ApplicationSI")
Const ORIGIN_WINTYPE_WKS = 2
Dim name As String, realname As String
name = "MyWorksheet"
realname = oApp.CreatePage(ORIGIN_WINTYPE_WKS, name, "Origin")
C#
static void Main(string[] args)
{
Origin.IOApplication pOrigin;
pOrigin = new Origin.ApplicationSIClass();
string strName = pOrigin.CreatePage((int)Origin.PAGETYPES.OPT_WORKSHEET, "OriginLab", "Origin", 2); //2 mean visible, create new workbook
pOrigin.PageBases[strName].Activate(); //make it as active page
}
Python
import OriginExt as O
app = O.Application(); app.Visible = app.MAINWND_SHOW
grPageName = app.CreatePage(app.OPT_GRAPH)
import random
import win32com.client # COM module
# Connect to Origin
origin = win32com.client.Dispatch("Origin.ApplicationSI")
# Create a new workbook named "Python" using the "origin" template
pageName = origin.CreatePage(2, "Python", "origin") # 2 for WorksheetPage
# Generate X data to be the even numbers from zero to 100.
# Note: the end of range is exclusive
xData = range(0,101,2)
# Generate Y data to be random numbers
yData = []
for i in range(0,len(xData)):
yData.append(random.random())
# Put the X and Y data into the worksheet
origin.PutWorksheet(pageName, xData, 0, 0) # row 0, col 0
origin.PutWorksheet(pageName, yData, 0, 1) # row 0, col 1
Version Information
8.0SR2
See Also
DestroyPage
|