3.2.9.1 Append, Insert New Layer


Version Info

Minimum Origin Version Required: Origin8 SR0

Append Layer

This example shows how to add a Worksheet in a workbook as the last one.

void wks_append_layer_ex()
{
	//Create a new Workbook with template file "Origin.OGW"
    WorksheetPage wp;
    wp.Create("ORIGIN");
    
    //Add a new layer named "MyLayer1" to the workbook
	wp.AddLayer("MyLayer1");
	
    //Add a new layer named "MyLayer2" to the workbook use template file "FFT.OGW"
    DWORD dwOptions = 0; // default can be 0
	wp.AddLayer("MyLayer2", dwOptions, "FFT.OTW");
}

Insert Layer

This example shows how to insert a Worksheet in one workbook to another workbook at specified position.

void wks_insert_layer_ex()
{
    WorksheetPage wksPage;
    wksPage.Create("Origin"); // create a worksheet page with one layer    
    
    int nNewLayer = wksPage.AddLayer("MyLayer");
    int nDestLayer = 0;
    bool bRet = wksPage.Reorder(nNewLayer, nDestLayer); // to move MyLayer as the first sheet  
    if( bRet )
    {
		string	strLT = wksPage.GetName() + "!page.active=" + (nDestLayer + 1);
		LT_execute(strLT); // to activate the first layer
    }
}