Skip to content

Workbooks

Excel workbooks with live formulas, tables, pivot tables, conditional formats, charts and sparklines.

Workbooks.md

Artiwright builds .xlsx workbooks the way an analyst would: inputs in cells, results as formulas, and charts that read the cells. Artiwright calculates the formulas too (494 Excel functions), so agents and code can read results and check them before anyone opens the file.

  • Formulas that recalculate in Excel, including dynamic arrays and cross-sheet references.
  • Tables with styles, filters and total rows.
  • Pivot tables that Excel refreshes from their source.
  • Conditional formats: data bars, color scales, icon sets and rules.
  • Charts and sparklines that read their data from cells.
  • Data validation (dropdowns), named ranges, frozen panes, print setup and sheet protection.
  • Themes: the same presets as decks.

In an AI app, ask in plain words. The agent creates a workbook (kind: "workbook"), builds it with formulas, checks it and saves it:

Build a 12-month cash forecast with an input sheet for growth and margin, a scenario dropdown (base, upside, downside), formulas for every month, and a chart.

With Google ADK, use the spreadsheets skill: artiwright_agent(..., skill="spreadsheets").

import { Workbook } from "artiwright";
const book = Workbook.create({ theme: "ledger" });
const sheet = book.sheets.add("Budget");
sheet.range("A1:D1").values = [["Month", "Budget", "Actual", "Variance"]];
sheet.range("A2:C4").values = [
["Jul", 100, 96],
["Aug", 110, 118],
["Sep", 120, 121],
];
for (const row of [2, 3, 4]) sheet.range(`D${row}`).formula = `=C${row}-B${row}`;
sheet.tables.add("A1:D4", { name: "Budget" });
sheet.conditionalFormats.add("D2:D4", { type: "dataBar" });
sheet.charts.add("column", { data: "A1:C4", at: "F2", size: { w: 480, h: 280 }, title: "Budget and actual" });
await book.save("budget.xlsx");

npx artiwright help lists everything a sheet can do, for example npx artiwright help --search pivot.

Lint looks for the mistakes that make people distrust a spreadsheet: formula errors and circular references, numbers too wide for their column (####), charts with no data, drawings hiding values, numbers stored as text, typed-in numbers inside formulas, and unformatted large numbers. Finalize can also require key cells to hold specific values, for example a check cell that must be 0. See check and finalize.