On this page
LosOS Sheets
LosOS Sheets is a spreadsheet that is also a database. In LosOS Cloud's
files bar at https://<address>/cloud/files, choose New workbook; it
opens at /sheets with the new workbook selected. The box's search finds
LosOS Sheets and your workbooks by name. The grid you edit and the SQL you
query are two views of the same file: a grid edit is a database write, and a
change made through the query view or the file shows up in the grid on the
next load.

Workbooks, sheets and fields
A workbook is one SQLite (libSQL-readable) database under
/var/lib/losos-sheets. Each sheet in it is a real SQL table: its columns
are typed fields and its rows are records. A field can be text, number,
boolean, date, formula or mdx. The human names you give fields are
stored as data; the SQL columns have generated names, so a name you type
cannot become a statement.
Use New workbook, Add sheet and Add column to make one. A cell is saved when you leave its input.
Formulas
A formula starts with =, for example =Qty*2, =SUM(Subtotal2:Subtotal9)
or =IF(Qty>10;"many";"few"). The same small grammar is used in the box and
in the browser: the browser evaluates it in WebAssembly so the grid can show
a value while you type, and the service checks that it translates to a
single SQL expression before storing it. Only SUM, AVG, MIN, MAX,
COUNT, ABS, ROUND, POWER, LEN, UPPER, LOWER, COALESCE and
IF exist, plus arithmetic, comparisons and & for joining text. A cell
that cannot be expressed is refused; it is never run as SQL or JavaScript.
MDX cells
An mdx cell holds MDX source. The page renders it with the same
losos-mdx crate the box uses, compiled to WebAssembly: a fixed set of
components, no expressions or imports, and an allowlist of tags,
attributes and URL schemes. A <script>, an event handler or a
javascript: link cannot reach the page. Choose Edit MDX on a cell to
change its source.
The SQL view
SQL at the top of the sheet opens a read-only query box. It accepts one
SELECT or WITH statement without a semicolon, on a connection with
query_only set. The result is a table of the same database the grid draws.
Writes, PRAGMA, ATTACH and multiple statements are refused.
Bringing spreadsheets in
In the page, Import Excel takes an .xlsx, .xlsm or .xls file.
Sheet names, headers, typed columns, values and formulas are converted; a
formula the grammar cannot express is kept as its text and listed under
Import notes. An .xls formula is imported as its cached value because
that format stores formula tokens rather than source text; save as .xlsx
to translate them.
The same path is a command on the box:
losos-sheets import-excel budget.xlsx --root /var/lib/losos-sheets --name Budget
It prints the new workbook's id and one line per note. The server offers
the same conversion at POST /sheets/api/import/excel.
Exporting to Excel and OpenDocument
The ribbon's Export Excel (.xlsx) and Export OpenDocument (.ods) download the whole workbook, one sheet per tab, with field names as the first row. Formulas are exported as their computed values; MDX cells are exported as their source text. Charts, merges and styles are not exported.
On the box:
losos-sheets export-xlsx <workbook-id> --root /var/lib/losos-sheets --out budget.xlsx
losos-sheets export-ods <workbook-id> --root /var/lib/losos-sheets --out budget.ods
The server offers the same downloads at
GET /sheets/api/workbooks/<id>/export.xlsx and
GET /sheets/api/workbooks/<id>/export.ods.
The native .sheets file
Export .sheets downloads a workbook as <id>.sheets; Import
.sheets reads one back. A .sheets file is a tar.xz archive with three
members:
| Member | What it carries |
|---|---|
manifest.json | format version, workbook name and sheet ids |
workbook.db | the SQLite/libSQL database |
document.mdx | every MDX cell, tagged by sheet, column and row |
On the box:
losos-sheets export <workbook-id> --root /var/lib/losos-sheets --out budget.sheets
losos-sheets import-sheets budget.sheets --root /var/lib/losos-sheets
Import is deliberately narrow. An archive is refused if a member is not one
of those three names, is absolute or contains .., is not a regular file,
or exceeds the size and entry-count caps. The database is checked for a
SQLite header before it is written, and every MDX cell is passed through
the sanitizer first. Nothing in the file is executed.
To check an MDX cell from a terminal:
losos-sheets render-mdx cell.mdx
The module is on by default (losos.sheets.enable). It runs as the
unprivileged losos-sheets user on a Unix socket that only nginx's group
can open, behind LosOS Login. Its state lives under /var/lib/losos-sheets,
which is on the encrypted persistent volume.