Skip to Content
Vatson Office

Workbook spec

The WorkbookSpec that create_workbook takes. Sheets of cells with live formulas, roles, styles, tables, names and native charts.

A WorkbookSpec lists sheets of cells. Every derived number is a formula in English function names; inputs are plain values with role: "input", which the compiler colours blue on pale yellow. Tables, named ranges, conditional formats, validations and native charts are declared on the sheet; the compiler writes the XML, the styles and the number formats.

Cash-flow workbook: inputs in labelled cells, monthly formulas, totals and a column chart
A cash-flow plan from a WorkbookSpec, as LibreOffice renders it

Smallest example

create_workbook input
{
  "filename": "plan",
  "spec": {
    "locale": "en-US",
    "sheets": [
      {
        "name": "Plan",
        "cells": [
          { "ref": "A1", "value": "Unit price" }, { "ref": "B1", "value": 120, "role": "input" },
          { "ref": "A2", "value": "Units" }, { "ref": "B2", "value": 40, "role": "input" },
          { "ref": "A3", "value": "Revenue" }, { "ref": "B3", "formula": "=B1*B2" }
        ]
      }
    ]
  }
}

Rules the checks enforce

  • Live formulas. A number derived from other cells is a formula, never a typed result (W1).
  • Inputs in labelled cells. Formulas point at input cells or names, not typed constants (W2).
  • Formats on every number. Money with a currency, percentages, dates as YYYY-MM-DD strings that the compiler stores as real dates (W4).
  • English formula syntax. English function names and commas; Excel shows them localised (W5).
  • No missing sheets or names. A formula that refers to a sheet or name that does not exist is an error, and no file is made.

A full example

The spec behind the cash-flow plan in the example files.

Fields

Generated from the schema the tools send to the model. A field with ? is optional.

FieldTypeDescription
version?1
locale?stringBCP 47 tag for number and date formats; default from the host settings
title?string (max 255 chars)Workbook title in sentence case
accounting?booleanMoney and amount formats in the accounting style: (1,200) for negatives in English locales, a dash for zero, thousands separators. Default true; false keeps formats exactly as given
font?objectWorkbook font; default Calibri 11
styles?object[] (at most 100)
names?object[] (at most 500)
sheetsobject[] (at least 1, at most 50)

font

Workbook font; default Calibri 11

FieldTypeDescription
namestring (max 64 chars)
size?number (min 6, max 24)

styles[]

FieldTypeDescription
bold?boolean
italic?boolean
fontSize?number (min 6, max 48)
fontColor?string
fill?string
numFmt?string (max 255 chars)
align?"left" | "center" | "right"
valign?"top" | "middle" | "bottom"
wrap?boolean
indent?integer (min 0, max 10)
border?"none" | "thin" | "medium" | "bottom" | "top" | "topBottom" | "doubleBottom"
idstring (max 64 chars)

names[]

FieldTypeDescription
namestring (max 255 chars)
refstring (min 2 chars)Sheet-qualified target, e.g. 'Assumptions'!$B$3
comment?string (max 255 chars)

sheets[]

FieldTypeDescription
id?string (max 64 chars)
namestring (max 31 chars)
title?string | falseTitle row written in A1 (the sheet moves down to make room). Default: the workbook title on the first sheet; false for none
tabColor?string
columns?object[]
freeze?object
cells?object[] (at most 50,000)
tables?object[] (at most 20)
merges?string[] (at most 500)
conditionalFormats?object[] (at most 100)
validations?object[] (at most 100)
charts?object[] (at most 20)
gridlines?booleanCell gridlines on screen. Default: hidden on a sheet with a table or a row of headers, shown elsewhere
landscape?boolean
notes?string[] (at most 6)Short lines under the sheet's tables (italic, grey): how to read it, sources, assumptions, what the placeholder colour means
autofilter?stringFilter buttons on the header row of this range (tables have their own)
sparklines?object[] (at most 1,000)
print?object

sheets[].columns[]

FieldTypeDescription
colstring
width?number (min 0, max 255)
hidden?boolean

sheets[].freeze

FieldTypeDescription
rowsinteger (min 0, max 100)
colsinteger (min 0, max 50)

sheets[].cells[]

FieldTypeDescription
refstringA1 cell reference on the same sheet, e.g. B3
value?string | number | boolean | nullLiteral value. Numbers as numbers, never as formatted text.
formula?stringExcel formula in English function names, with or without leading '='. Use for every derived number.
role?"input" | "calc" | "link" | "header" | "label" | "total" | "note"
style?string | objectNamed style id or inline style
note?string (max 2,000 chars)Cell comment, e.g. the source of an assumption
placeholder?booleanThe value is a stand-in the brief did not give: shown marked for the user to replace. In text, [[Name]] marks one too.

sheets[].cells[].style

FieldTypeDescription
bold?boolean
italic?boolean
fontSize?number (min 6, max 48)
fontColor?string
fill?string
numFmt?string (max 255 chars)
align?"left" | "center" | "right"
valign?"top" | "middle" | "bottom"
wrap?boolean
indent?integer (min 0, max 10)
border?"none" | "thin" | "medium" | "bottom" | "top" | "topBottom" | "doubleBottom"

sheets[].tables[]

FieldTypeDescription
id?string (max 64 chars)
name?string (max 255 chars)
atstringTop-left cell of the header row
columnsobject[] (at least 1, at most 100)
rows((string | number | boolean | null | object)[])[] (at most 1,000,000)Data rows; [] when rowsFrom names a CSV file
rowsFrom?string (max 1,024 chars)A CSV file the caller loads into rows (its header row is skipped), for large data; the engine never reads files
banded?boolean
totalsRow?boolean

sheets[].tables[].columns[]

FieldTypeDescription
headerstring (max 255 chars)
numFmt?string (max 255 chars)
role?"input" | "calc" | "link" | "header" | "label" | "total" | "note"
width?number (min 1, max 255)
total?"sum" | "average" | "count" | "min" | "max" | "none"

sheets[].conditionalFormats[]

FieldTypeDescription
rangestringA1 range on the same sheet, e.g. B2:B13
ruleobject
style?object

sheets[].conditionalFormats[].rule variant 1

FieldTypeDescription
type"cellIs"
operator"gt" | "gte" | "lt" | "lte" | "eq" | "neq" | "between"
valuenumber | string
value2?number | string

sheets[].conditionalFormats[].rule variant 2

FieldTypeDescription
type"formula"
formulastring

sheets[].conditionalFormats[].rule variant 3

FieldTypeDescription
type"colorScale"
minColorstring
midColor?string
maxColorstring

sheets[].conditionalFormats[].rule variant 4

FieldTypeDescription
type"dataBar"
colorstring

sheets[].conditionalFormats[].rule variant 5

FieldTypeDescription
type"iconSet"
icons?"3arrows" | "3trafficLights" | "3symbols" | "3flags" | "4arrows" | "4rating" | "5arrows" | "5rating"
reverse?boolean
showValue?booleanDefault true; false shows the icon only

sheets[].conditionalFormats[].rule variant 6

FieldTypeDescription
type"top" | "bottom"
rankinteger (min 1, max 1,000)
percent?booleanrank is a percentage of the cells

sheets[].conditionalFormats[].rule variant 7

FieldTypeDescription
type"aboveAverage"
below?boolean

sheets[].conditionalFormats[].rule variant 8

FieldTypeDescription
type"containsText"
textstring (max 255 chars)

sheets[].conditionalFormats[].rule variant 9

FieldTypeDescription
type"duplicates"
unique?booleanHighlight values that appear once instead

sheets[].conditionalFormats[].style

FieldTypeDescription
bold?boolean
fontColor?string
fill?string

sheets[].validations[]

FieldTypeDescription
rangestringA1 range on the same sheet, e.g. B2:B13
type"list" | "whole" | "decimal" | "date" | "textLength"
values?string[] (at most 255)Allowed values for type=list
source?string (min 2 chars)Range or defined name holding the allowed values for type=list
min?number
max?number
promptTitle?string (max 32 chars)
prompt?string (max 255 chars)Input message shown when the cell is selected
errorTitle?string (max 32 chars)
error?string (max 255 chars)
errorStyle?"stop" | "warning" | "information"Default stop: a wrong value is refused

sheets[].charts[]

FieldTypeDescription
id?string (max 64 chars)
type"column" | "bar" | "line" | "area" | "pie" | "doughnut" | "scatter" | "waterfall"waterfall: one series of changes, drawn as stacked columns (Excel's own waterfall type is not written)
stacked?boolean | "percent"true stacks; "percent" stacks to 100%
title?string (max 255 chars)
anchorstringTop-left cell the chart is placed at
widthCols?integer (min 2, max 40)
heightRows?integer (min 5, max 80)
categories?string (min 2 chars)Category labels range, e.g. 'Sales 2026'!A2:A13
seriesobject[] (at least 1, at most 12)
yAxis?object
y2Axis?objectThe secondary value axis
totalLast?booleanwaterfall: the last point is a total bar, not a change
xAxis?object
legend?"bottom" | "right" | "top" | "none"
showValues?booleanA value label on every point. Default: on for column, bar and line charts with at most 8 points

sheets[].charts[].series[]

FieldTypeDescription
name?string (max 255 chars)
valuesstring (min 2 chars)Range or defined name holding the allowed values for type=list
color?string
type?"column" | "line" | "area"Combo chart: this series as columns, a line or an area
secondaryAxis?booleanPlot on a second value axis on the right (combo charts)

sheets[].charts[].yAxis

FieldTypeDescription
title?string (max 255 chars)
numFmt?string (max 255 chars)

sheets[].charts[].y2Axis

The secondary value axis

FieldTypeDescription
title?string (max 255 chars)
numFmt?string (max 255 chars)

sheets[].charts[].xAxis

FieldTypeDescription
title?string (max 255 chars)

sheets[].sparklines[]

FieldTypeDescription
atstringCell the sparkline is drawn in
rangestring (min 2 chars)One row or column of values, e.g. B2:M2
type?"line" | "column" | "winLoss"
color?string
markers?booleanLine: a marker on every point
highLow?booleanMark the highest and lowest point

sheets[].print

FieldTypeDescription
repeatRows?integer (min 1, max 50)Top rows repeated on every printed page (the header)
repeatCols?integer (min 1, max 20)Left columns repeated on every printed page
fitWidth?booleanFit all columns on one page width. Default: when they nearly fit
landscape?boolean
paper?"A4" | "letter"Default from the locale
gridlines?booleanPrint the gridlines
centre?booleanCentre the sheet horizontally on the page. Default true

On this page