Options for Layer


Syntax: layer -d

Delete the active layer, but keep data (in loose datasets).

This will delete the sheet and if last sheet deleted, the book will be deleted as well.

This command was expanded as follows:

layer -d name; // del layer/sheet in active page 
layer -d [book]sheet;// general range notation

Also supported are the accompanying d, k, and u switches,

layer -dd;  // del active layer, delete data too
layer -du;  // del active layer, adding undo 
layer -dk;  // del active layer, keeping book if last sheet is deleted
layer -duk; // del active layer, with both 'u' and 'k' options


  • -duk and -dku are the same
  • If u switch is used on non-active book, then it will first be activated before del, as only active book supports undo.

To delete the last sheet/layer in current window, generally you can use page.nlayers to get the index of last layer/sheet:

layer -d $(page.nlayers); //page.nlayers is the number of sheets/layers in current page and also the index of the last sheet/layer.

Since Origin 2021b, you can easily use 0 to specify the last sheet/layer,

layer -d 0;


Syntax: layer -dk

Delete the active layer. The book is kept undeleted.

This will delete the active layer from the active book and keep the book even if all sheets are deleted.


Syntax: layer -f

Duplicate a worksheet or matrixsheet.


Syntax: layer -h value

Hide or Show the layer. If value = 1, hide the layer. If value = 0, show the layer. This command does not automatically refresh the window display.


Syntax: layer -m

Open the Layer Clipping Margins dialog box for the active layer.


Syntax: layer -o layerNumber / layerName {script}

Execute (operate) the specified script for the specified layer.

// Paste the current time on layer 2 of graph1
layer -o [graph1]2 {label -s -t $(@D, D10)}

// Fill data to column B on specified sheet
newbook sheet:=3 result:=bn$;
layer -o [bn$]Sheet2 {
	col(b)=data(1, 10);


Syntax: layer -s n

Select the active layer in the active window. The integer n specifies the layer number. You can also set (and get) the active layer number using the page.active object property.


Given three layers, the following script sizes each layer to 20% of the page width and 80% of the page height. It arranges the layers 10% from the top of the page, starting at 8% in from the left, and separated by 12% of the full page.

width = 20;
height = 80;
for (ii = 1; ii <= 3; ii++) 
            layer -s ii;
            layer width height (8+(ii-1)*(width+12)) 10;


Syntax: layer -tm nrow ncol bLabel

Return merged cell range:
If cell at nrow and ncol is within a merged group of cells, the column and row range of the cells is returned (e.g. "cell merged range c1=1 c2=2 r1=4 r2=6").