Skip to content

vgrid sheet

Sheet file operations for headless build, inspect, and verify workflows.

Build a .sheet file from a Lua script (replacement semantics).

Terminal window
vgrid sheet apply <output> --lua <script> [options]
OptionDescription
--luaPath to Lua build script (required)
--verifyVerify fingerprint after build (exit 1 if mismatch)
--stampStamp file with expected fingerprint; optional label e.g. --stamp "MSFT SEC v1"
--dry-runCompute fingerprint but don’t write file
--jsonOutput as JSON

The Lua script builds the sheet using these functions:

  • set(cell, value) — set cell value or formula
  • clear(cell) — clear cell
  • meta(target, table) — semantic metadata (affects fingerprint)
  • style(target, table) — presentation style (excluded from fingerprint)
Terminal window
# Build a sheet from Lua
vgrid sheet apply model.sheet --lua build.lua
# Build and verify fingerprint
vgrid sheet apply model.sheet --lua build.lua --verify v1:42:abc123...
# Dry run — compute fingerprint without writing
vgrid sheet apply model.sheet --lua build.lua --dry-run
# Build and stamp for GUI verification
vgrid sheet apply model.sheet --lua build.lua --stamp "Q4 Close v2"

Inspect cells, ranges, or workbook metadata in a .sheet file.

Terminal window
vgrid sheet inspect <file> [target] [options]
OptionDescription
--workbookShow workbook metadata (fingerprint, sheet count)
--sheetSelect sheet by 0-based index or name (case-insensitive). Default: sheet 0
--sheetsList all sheets with dimensions and non-empty cell counts
--non-emptyOnly include non-empty cells (sparse output — returns SparseInspectResult schema)
--include-styleInclude style information
--headersTreat first row as column headers (adds column_name to JSON/NDJSON output)
--formatExplicit format override: sheet, xlsx, csv, tsv (inferred from extension if omitted)
--delimiterCSV field delimiter (single char or name: tab, comma, pipe, semicolon)
--calc <expr>Evaluate formula against loaded data (repeatable). Output is always JSON. Exit 1 if any formula errors
--lightweightQuery SQLite directly without loading the full workbook. Skips formula recomputation and formatting. Only works with .sheet files. Ideal for server-side use
--jsonOutput as JSON
--ndjsonOutput as newline-delimited JSON (one object per line, streamable)
Terminal window
# Inspect a cell
vgrid sheet inspect model.sheet A1
# Inspect a range
vgrid sheet inspect model.sheet A1:D10
# Workbook metadata
vgrid sheet inspect model.sheet --workbook
# JSON output with styles
vgrid sheet inspect model.sheet A1 --json --include-style
# List all sheets in a workbook
vgrid sheet inspect model.sheet --sheets --json
# Inspect a cell on a specific sheet (by index)
vgrid sheet inspect model.sheet --sheet 1 A1 --json
# Inspect a cell on a specific sheet (by name)
vgrid sheet inspect model.sheet --sheet Forecast B5 --json
# Sparse: all non-empty cells on a sheet
vgrid sheet inspect model.sheet --sheet Forecast --non-empty --json
# Sparse: non-empty cells within a range
vgrid sheet inspect model.sheet --sheet 1 A1:M100 --non-empty --json
Terminal window
# Streamable NDJSON output (one cell per line)
vgrid sheet inspect model.sheet --sheet Forecast --non-empty --ndjson
# Evaluate formulas against data (always JSON output)
vgrid sheet inspect data.csv --headers --calc "SUM(Amount)" --calc "SUM(Tax)"
# Inspect a CSV with explicit delimiter
vgrid sheet inspect data.tsv --format tsv --headers --json

--lightweight queries the .sheet file’s SQLite database directly, without loading cells into memory, rebuilding the dependency graph, or recomputing formulas. Formula cells return their last-saved cached values. This makes it safe for memory-constrained servers (e.g. 2 GB RAM) processing large workbooks.

Terminal window
# List sheets (SQL aggregates — no cell data loaded)
vgrid sheet inspect model.sheet --sheets --lightweight --json
# Preview first 100 rows (bounded SQL query)
vgrid sheet inspect model.sheet A1:Z101 --lightweight --json
# Workbook summary (sheet count + cell count only, no fingerprint)
vgrid sheet inspect model.sheet --lightweight --json

--lightweight cannot be combined with --calc, --include-style, or --value.

If --sheet references an invalid index or name, the error message lists available sheets.

ModeSchema
--sheetsArray of SheetListEntry (index, name, non_empty_cells, max_row, max_col)
--non-emptySparseInspectResult (sheet_index, sheet_name, range?, cells[])
Default cell/rangeCellInspectResult / RangeInspectResult (unchanged)
--ndjsonOne JSON object per line (same fields as --json, streamable)

--sheet is supported for .sheet and .xlsx only. --non-empty always returns SparseInspectResult schema. --ndjson emits one JSON object per line with no wrapper — suitable for streaming pipes and incremental agent processing.

Verify a .sheet file’s semantic fingerprint.

Terminal window
vgrid sheet verify <file> [options]
OptionDescription
--fingerprintExpected fingerprint (reads from file’s embedded fingerprint if not provided)
Terminal window
# Verify using embedded fingerprint
vgrid sheet verify model.sheet
# Verify against explicit fingerprint
vgrid sheet verify model.sheet --fingerprint v1:42:abc123
Exit codeMeaning
0Verified (fingerprint matches)
1Drifted (fingerprint mismatch) or Unverified (no expected fingerprint)
2Usage error

Compute and print a .sheet file’s fingerprint.

Terminal window
vgrid sheet fingerprint <file> [options]
OptionDescription
--jsonOutput as JSON
Terminal window
vgrid sheet fingerprint model.sheet
vgrid sheet fingerprint model.sheet --json

Import a foreign spreadsheet into canonical .sheet format.

Terminal window
vgrid sheet import <source> <output> [options]
OptionDescription
--sheetSheet to import by index or name (XLSX only)
--headersTreat first row as column headers
--formulasFormula handling: values (default), keep, recalc
--nullsEmpty cell handling: empty (default), error
--stamp [label]Stamp with provenance fingerprint + optional label
--verifyVerify fingerprint matches (exit 1 on mismatch)
--dry-runCompute fingerprint without writing file
--jsonOutput structured JSON summary
--delimiterCSV field delimiter
Terminal window
# Import CSV
vgrid sheet import data.csv data.sheet --headers
# Import XLSX with specific sheet
vgrid sheet import report.xlsx data.sheet --sheet Revenue
# Import and stamp for verification
vgrid sheet import data.csv data.sheet --headers --stamp "Q4 Filing"
# Dry run — compute fingerprint without writing
vgrid sheet import data.csv data.sheet --headers --dry-run --json