Scripting with ARexx

CellBasics exposes an ARexx port, so scripts can drive it the same way you would by hand — open and save documents, move the selection around, read and write cell values, apply formatting and more. Commands are sent to the running application's ARexx port.

Most commands act on the active document and its current selection: you typically SELECT a cell or range first, then run a command that reads or changes it. Query commands (the GET… family, VALUE, SELECTION, COLUMNS, and so on) return their answer in the ARexx RESULT variable.

A short example:

/* fill A1 and read it back */
ADDRESS 'CELLBASICS'
NEW
SELECT 'A1'
SETVALUE 'Hello'
BOLD ON
VALUE
SAY RESULT          /* => Hello */

In the reference below, arguments shown in [brackets] are optional.

Command reference

63 ARexx commands are available, grouped by area. Type in the box to filter by name or keyword.

Document (4)

NEW

NEW

clear the document

OPEN

OPEN path

load a document

SAVE

SAVE

save a document

SAVEAS

SAVEAS path

save a document to path

Clipboard & History (7)

UNDO

UNDO

undo the last operation

REDO

REDO

redo the last undone operation

COPY

COPY

copy the current selection to the clipboard

CUT

CUT

cut the current selection to the clipboard

COPYVALUES

COPYVALUES

copy the current selection to the clipboard as values only (formulas discarded)

PASTE

PASTE

paste the clipboard contents starting at the current selection

PASTEVALUES

PASTEVALUES

paste the clipboard contents as values only (formulas discarded) starting at the current selection

Selection & Values (6)

SELECT

SELECT cell or range

select a cell or range (A1, A1:A2, etc)

SELECTION

SELECTION

return current selection

VALUE

VALUE

return value(s) at current selection

NUMERICALVALUE

NUMERICALVALUE

return a number at current selection (discards formatting of dates, etc)

SETVALUE

SETVALUE value

enter value into selected cell(s)

RUNFORMULA

RUNFORMULA formula

run a given formula at currently selected cell, return the result

Sheets & Structure (13)

COLUMNS

COLUMNS

column count (active sheet)

ROWS

ROWS

row count (active sheet)

SHEET

SHEET

1-based index of active sheet

SHEETS

SHEETS

number of sheets in document

SELECTSHEET

SELECTSHEET index

select sheet at index (1-based)

INSERTROW

INSERTROW position

1-based position to insert a new row at

INSERTCOLUMN

INSERTCOLUMN position

1-based position to insert a new column at

DELETEROW

DELETEROW position

delete row at 1-based position index

DELETECOLUMN

DELETECOLUMN position

delete column at 1-based position index

INSERTCELLSDOWN

INSERTCELLSDOWN

insert cells over the current selection, shifting existing cells down within the selected columns

INSERTCELLSRIGHT

INSERTCELLSRIGHT

insert cells over the current selection, shifting existing cells right within the selected rows

DELETECELLSUP

DELETECELLSUP

delete cells in the current selection, pulling cells below up within the selected columns

DELETECELLSLEFT

DELETECELLSLEFT

delete cells in the current selection, pulling cells to the right left within the selected rows

Formatting (14)

SETFONT

SETFONT name

set the font of the current selection

SETFONTSIZE

SETFONTSIZE size

set the font size (in points) of the current selection

BOLD

BOLD state

set bold on the current selection (ON/OFF, also accepts 1/0/TRUE/YES)

ITALIC

ITALIC state

set italic on the current selection (ON/OFF, also accepts 1/0/TRUE/YES)

UNDERLINE

UNDERLINE state

set underline on the current selection (NONE, SINGLE or DOUBLE; defaults to SINGLE)

STRIKETHROUGH

STRIKETHROUGH state

set strikethrough on the current selection (NONE, SINGLE or DOUBLE; defaults to SINGLE)

TEXTCOLOR

TEXTCOLOR color

set the text color of the current selection, as a hexadecimal RRGGBB value (e.g. FF0000, optional leading #)

BGCOLOR

BGCOLOR color

set the background (fill) color of the current selection, as a hexadecimal RRGGBB value, or TRANSPARENT/NONE to clear it

ALIGN

ALIGN alignment

set the horizontal alignment of the current selection (LEFT, CENTER, RIGHT or JUSTIFY)

VALIGN

VALIGN alignment

set the vertical alignment of the current selection (TOP, CENTER or BOTTOM)

LINEWRAP

LINEWRAP state

set line wrapping on the current selection (ON/OFF, also accepts 1/0/TRUE/YES)

MERGE

MERGE

merge the current selection into a single cell

UNMERGE

UNMERGE

split any merged cells in the current selection

FRAME

FRAME edges [style] [color]

set the border (frame) style of the current selection. edges selects which borders to set: ALL, OUTER, INSIDE, INSIDEH, INSIDEV, TOP, BOTTOM, LEFT, RIGHT, or NONE to clear all borders. Only the named edges are changed, the rest are left untouched. style (optional) is the line style: THIN (default), THICK, MEDIUM, HAIR, DASHED, DOTTED, DOUBLE, DASHDOT, DASHDOTDOT, MEDIUMDASHED, MEDIUMDASHDOT, MEDIUMDASHDOTDOT or SLANTDASHDOT. color (optional) is a hexadecimal RRGGBB value (defaults to black)

Reading Formatting (12)

GETFONT

GETFONT

return the font name of the current selection (empty if it has multiple values)

GETFONTSIZE

GETFONTSIZE

return the font size of the current selection (empty if it has multiple values)

GETBOLD

GETBOLD

return ON or OFF for the current selection (empty if it has multiple values)

GETITALIC

GETITALIC

return ON or OFF for the current selection (empty if it has multiple values)

GETUNDERLINE

GETUNDERLINE

return NONE, SINGLE or DOUBLE for the current selection (empty if it has multiple values)

GETSTRIKETHROUGH

GETSTRIKETHROUGH

return NONE, SINGLE or DOUBLE for the current selection (empty if it has multiple values)

GETTEXTCOLOR

GETTEXTCOLOR

return the text color of the active cell as a hexadecimal RRGGBB value

GETBGCOLOR

GETBGCOLOR

return the background (fill) color of the active cell as a hexadecimal RRGGBB value, or TRANSPARENT

GETALIGN

GETALIGN

return the horizontal alignment of the current selection (LEFT, CENTER, RIGHT, JUSTIFY or AUTOMATIC; empty if it has multiple values)

GETVALIGN

GETVALIGN

return the vertical alignment of the current selection (TOP, CENTER, BOTTOM or AUTOMATIC; empty if it has multiple values)

GETLINEWRAP

GETLINEWRAP

return ON or OFF for the current selection (empty if it has multiple values)

GETFRAME

GETFRAME [edge]

return the border (frame) style of the active cell. With an edge argument (TOP, BOTTOM, LEFT or RIGHT) it returns that edge's style; without one it returns all four edges as "TOP:style BOTTOM:style LEFT:style RIGHT:style". See FRAME for the list of style names.

Data Type & Number Format (6)

SETTYPE

SETTYPE type

set the data type of the current selection: AUTOMATIC, WHOLENUMBER, NUMBER (or DECIMAL), TEXT, DATE, DATETIME, TIME, TIMEDELTA or CURRENCY. The appropriate default format is applied.

SETDATEFORMAT

SETDATEFORMAT format

set a date/time format string on the current selection (e.g. YYYY-MM-DD)

CHANGEDECIMALS

CHANGEDECIMALS delta

change the number of decimal places of the current selection by delta (e.g. 1 or -1)

SETDECIMALS

SETDECIMALS precision

set the number of decimal places of the current selection to precision

SETSEPARATORS

SETSEPARATORS state

toggle thousands separators on the current selection (ON/OFF, also accepts 1/0/TRUE/YES)

SETCURRENCY

SETCURRENCY symbol

set the currency symbol of the current selection

Data (1)

SORT

SORT column [column ...]

sort the rows of the current selection by one or more columns, primary key first. Each column is a column letter optionally followed by a sort direction, separated by a colon: ASC/ASCENDING/A (the default) or DESC/DESCENDING/D, e.g. A, B:DESC, C:ASC. For example, SORT A C:DESC B sorts ascending by column A, then descending by C, then ascending by B. Undoable as a single operation.

No commands match your search.