NATS live data in Excel

Subscribe to NATS subjects with a formula. Publish cell values back. No development required — download the pre-built .xll and load it straight into Excel. MIT licensed and free to use.

Download .xll View source

Functions

Subscribe, aggregate, and publish. All from a cell formula.

NATS.SUB(subject, [type])
Subscribe to a subject. Cell updates live as messages arrive. The optional second argument controls type handling: omit for automatic detection, or pass number, bool, string, or a JSON path to extract a field.
=NATS.SUB("prices.AAPL") — auto type detection
=NATS.SUB("sensor.state", "bool") — force boolean
=NATS.SUB("ticker.AAPL", "$.price") — extract JSON field
NATS.SUBWIN(subject, n, [type])
Buffer the last N values. Spills into a range for use with AVERAGE, STDEV, etc. Accepts the same type hints as NATS.SUB.
=NATS.SUBWIN("sensor.temp", 60)
=NATS.SUBWIN("trade", 20, "$.price") — JSON path
=AVERAGE(NATS.SUBWIN("sensor.temp", 60))
NATS.PUB(subject, value)
Publish a cell value to a subject whenever it changes. Reactive publishing.
=NATS.PUB("alerts.drift", B7)
=NATS.PUB("commands.target", C2)
JSON path extraction
Extract fields from JSON payloads using dot-path syntax in any subscription formula.
=NATS.SUB("trade", "$.price")
=NATS.SUBWIN("trade", 20, "$.qty")

Build your own wrappers

NATS.SUB is a general-purpose function, but you can build typed wrappers that embed your own subject naming conventions. A custom RTD function wrapping the same infrastructure gives users a cleaner, domain-specific API.

Instead of exposing raw NATS subjects to spreadsheet users, they get functions that match your schema. The subject construction happens in Zig. Parameter names, descriptions, and category all surface in Excel's formula bar and Insert Function dialog.

custom wrapper
// Generic
=NATS.SUB("acmeco.trades.AAPL.vwap")

// Your wrapper - same RTD infrastructure,
// subject construction in Zig
=ACMECO.TRADES("AAPL", "vwap")

How it works

The connector is built on zigxll's RTD server framework. The NATS client (via the official nats.c library) runs on a background thread pool. Incoming messages are handed off to Excel's RTD polling mechanism lock-free.

RTD registration writes to HKCU automatically when the XLL loads.

Memory is arena-allocated per refresh cycle. UTF-16 conversions for Excel and null-terminated subject copies for the C API are handled transparently.

  • Built on zigxll's RTD server framework
  • Official nats.c library
  • Lock-free handoff from nats.c thread pool to Excel RTD
  • TLS, NKey, token, and credentials file authentication
  • Cluster failover support
  • Automatic type conversion (numbers, strings, booleans)
  • Excel dynamic array support, results spill into ranges
  • Pre-built signed binaries available: plain (no deps) and TLS (requires OpenSSL)

Excel as a stream processor

Excel is already a reactive computation engine with decades of financial modelling, statistical, and domain-specific functions built in. It recalculates on change, supports rich visualisation, and is the tool analysts already use. Connect it to NATS and that computation runs against live data instead of snapshots.

A worked example: a Python script publishes FX tick data to NATS. Excel subscribes, derives cross-rates, computes rolling statistics, detects breakouts, and publishes alerts back to NATS. Downstream subscribers receive those alerts without knowing their source.

Three new functions. No Kubernetes. No stream processing framework. Useful for analysts who already live in Excel and want to wire directly into event infrastructure, or for prototyping pipeline logic against live data before porting it somewhere more robust.

Read the full write-up →

FX monitoring workbook
Raw feed
=NATS.SUB("fx.raw.EURUSD.bid")
Derived cross-rate
=Raw!D2/Raw!D3
Rolling volatility (60 ticks)
=STDEV(NATS.SUBWIN("fx.raw.EURUSD.mid", 60))
Breakout alert, published back
=NATS.PUB("fx.derived.alerts", B2)

Configuration

Drop a config.json alongside the .xll or in %APPDATA%\zigxll-nats\. Supports TLS, works with Synadia Cloud, and all standard auth schemes.

config.json
{
  "server":              "nats://127.0.0.1:4222", // or nats://user:pass@host:4222
  "servers":             ["nats://n1:4222", "nats://n2:4222"], // multiple URLs for failover
  "tls":                 false,
  "credentials_file":   "",               // path to .creds file for NKey/JWT auth
  "token":               "",               // token auth
  "connect_timeout_ms": 5000,
  "reconnect_wait_ms":  2000
}

Download

Download the pre-built .xll, drop it anywhere, double-click to load in Excel. No development required. MIT licensed — free to use, fork, or embed. If you do find it useful, we’d love to hear what you’re building with it.

Download release Build from source