vimsheet.scripting.engine

VimSheet scripting engine — executes a mini-DSL of spreadsheet commands.

class vimsheet.scripting.engine.ScriptResult(commands_run=0, errors=<factory>)[source]

Bases: object

Outcome of running a script.

Parameters:
commands_run: int = 0
errors: list[str]
property ok: bool
__init__(commands_run=0, errors=<factory>)
Parameters:
Return type:

None

exception vimsheet.scripting.engine.ScriptError[source]

Bases: Exception

Raised when a script command cannot be executed.

class vimsheet.scripting.engine.ScriptEngine(workbook=None)[source]

Bases: object

Execute VimSheet script commands against a Workbook.

Script syntax — one command per line; lines starting with # are comments:

# Set values
set A1 = Hello
set B1 = 42
formula C1 = =SUM(A1:B1)

# Formatting
format A1 bold=true align=left

# Sheet ops
addsheet Sales
sheet Sheet1

# File ops
open data.csv
save output.xlsx

# Column width
colwidth A 15
autofit B

# Sort
sort 1 asc
Parameters:

workbook (Workbook | None)

__init__(workbook=None)[source]
Parameters:

workbook (Workbook | None)

Return type:

None

workbook: Workbook
run_file(path)[source]

Execute all commands in path.

Parameters:

path (Path)

Return type:

ScriptResult

run_string(script)[source]

Execute all commands in script string.

Parameters:

script (str)

Return type:

ScriptResult

run_lines(lines)[source]

Execute a sequence of command lines.

Parameters:

lines (list[str])

Return type:

ScriptResult