2.2.4.8.3 DataPlot::ChangeSheet

Version Info

Minimum Origin Version Required: Origin 9.1 SR0

Description

Change data plot to use another sheet.

Syntax

BOOL ChangeSheet(LPCSTR pcszWksName)
BOOL ChangeSheet(Worksheet& wks)

Parameters

pcszWksName
[input]name of the worksheet.
wks
[input]worksheet object.

Return

TRUE for success; FALSE otherwise.

Examples

EX1

void DataPlot_ChangeSheet_ex1()
{
	// Create a new workbook.
	WorksheetPage wpg;
	if( wpg.Create("origin") )
	{
		// Put some random data into the first worksheet.
		Worksheet wks = wpg.Layers();
		wks.Columns(0).SetFormula("i");
		wks.Columns(0).ExecuteFormula(0, -1, FALSE, 0, 0);
		wks.Columns(1).SetFormula("uniform(32,0.1)");
		wks.Columns(1).ExecuteFormula(0, -1, FALSE, 1, 1);

		// Plot the first sheet.
		wpg.LT_execute("plotxy iy:=(2)");

		// Add a 2nd worksheet with some random data.
		int i = wpg.AddLayer();
		wks = wpg.Layers(i);
		wks.Columns(0).SetFormula("i*1.2");
		wks.Columns(0).ExecuteFormula(0, -1, FALSE, 0, 0);
		wks.Columns(1).SetFormula("uniform(32,0.1)");
		wks.Columns(1).ExecuteFormula(0, -1, FALSE, 1, 1);
	}

	// Now we have a workbook with two worksheets and a graph
	// containing a dataplot data from Sheet1.

	GraphLayer gl = Project.ActiveLayer();
	if( gl )
	{
		DataPlot dp = gl.DataPlots(0);
		if( dp )
		{
			// Get 2nd worksheet and change data plot to use it.
			Worksheet wks2 = wpg.Layers(1);
			dp.ChangeSheet(wks2);
		}
	}
}

Remark

See Also

DataPlot::ChangeData

Header to Include

origin.h