spread-cli 0.3.3

Converts spreadsheets and CSV files to a friendly JSON format with many field name and data-type options.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
[![mirror](https://img.shields.io/badge/mirror-github-blue)](https://github.com/neilg63/spreadsheet_to_json_cli)
[![crates.io](https://img.shields.io/crates/v/spread-cli.svg)](https://crates.io/crates/spread-cli)
[![docs.rs](https://docs.rs/spread-cli/badge.svg)](https://docs.rs/spread-cli)

# Spreadsheet to JSON CLI (spread-cli)

Converts spreadsheets and CSV/TSV files to JSON, JSON Lines, or plain text -- designed to pipe straight into `jq`/`yq`.

Supported formats:

- Excel 2007+ Workbook (*.xlsx*)
- Excel 2007+ Macro-Enabled Workbook (*.xlsm*) -- read as plain data; macros are ignored
- Excel 2007+ Binary (*.xlsb*)
- Excel 97-2004 Legacy (*.xls*)
- OpenDocument Spreadsheets (*.ods*) compatible with LibreOffice
- CSV: comma separated values (*.csv*)
- TSV: tab-separated values (*.tsv*)

## Installation

```sh
cargo install spread-cli
```

Installs the `spread-cli` binary to `~/.cargo/bin`, already on your `PATH` via [rustup](https://rustup.rs) -- ready to use right away. (This is `cargo install`, not `cargo add` -- `cargo add` only adds a dependency to a Rust project; it won't put a binary on your `PATH`.)

## Quick start

```sh
spread-cli sales.xlsx                     # full result + metadata, human-readable (not valid JSON on its own)
spread-cli sales.xlsx -j                  # the same result, as one valid JSON object
spread-cli sales.xlsx -r | jq '.[0]'      # just the rows, as a JSON array -- for piping into jq/yq
spread-cli sales.xlsx -l | jq -c .        # just the rows, one compact JSON object per line (JSONL)
spread-cli big.xlsx -xpj | jq '.columns'  # explore a large multi-sheet workbook before pulling data out of it
```

Four things worth knowing up front:

1. **Piping into `jq`/`yq`?** You almost always want `-r` (rows as a JSON array) or `-l` (JSON Lines) -- see [Using with jq/yq](#using-with-jq-or-yq).
2. **Want one clean JSON object, metadata included?** Add `-j`/`--json`. Without it, the default full-result output is plain text (readable lines like `row count: 42`) with a JSON array only after the `data:` line -- the output as a whole is *not* valid JSON without `-j`. `-r`/`-l` output is always valid JSON/JSONL either way; `-j` there only changes indentation.
3. **Exploring an unfamiliar, large, multi-sheet workbook?** Start with `-x` (structural overview -- sheet names, row counts, field names, no cell values) combined with `-p` (every sheet, not just one); `-xpj` gives a clean JSON version. Then target the sheet(s)/field(s) you actually want with `-s`/`--keys`/`-r`/`-l`.
4. **Sheet and row numbers are 1-based** by default (`-n`, `-t`, `-b`), matching what you'd see in a spreadsheet app. 0-based equivalents exist for scripts that already track things by index -- see [Options](#options).

## Spreadsheet notes

Field names come from the header row, snake_cased (e.g. "Gross Annual Salary (USD)" becomes `gross_annual_salary_usd`). If the header isn't on the first row, `spread-cli` detects it automatically -- title/notes rows above it, and a gap before the real data starts, are recognized and skipped. Override with `-t`/`-b` if it guesses wrong, or `--omit-header` if there's no header row at all.

For wide spreadsheets with long or awkward header text, it's often easier to force every column to a short fallback key, then reassign the ones you care about with `--keys`, rather than typing out each header name in full -- `-A`/`--a1` for letters (`a`, `b`, ...) or `-R`/`--r1c1` for zero-padded numbers (`c01`, `c02`, ...):

```sh
spread-cli my-spreadsheet.xlsx -A --keys "a:first_name,b:last_name,c:salary,d:start_date"
spread-cli wide-report.xlsx -R --keys "c01:first_name,c27:region"
```

## Column mapping patterns (`--keys`) <a id="column-mapping-patterns-keys"></a>

### Nesting named columns (`old:a.b`) <a id="nesting-named-columns"></a>

A rename target containing dots nests the value under an object path instead of
flattening it. Sibling columns that share a prefix merge into the same object:

```
spread-cli loc.csv -rj --keys "lat:geo.lat,lng:geo.lng"
```

```
name,lat,lng
Littleton,53.1,-1.9
```

```json
[{"name": "Littleton", "geo": {"lat": 53.1, "lng": -1.9}}]
```

Paths can go any depth (`lat:place.geo.lat`), each segment is snake_cased like an
ordinary rename, and the usual `|format[|default]` suffix still applies
(`lat:geo.lat|float`). The nested field is addressable by the same path in
`--filter` (`"geo.lat > 52"`) and `--skip-cols` (`geo.lng`), and is listed by its
full path in the `fields` metadata. An empty segment (`geo.`, `.lat`, `geo..lat`) is
an error. So are two entries that would write to the same place: one name used
as both a value and an object (`lat:geo,lng:geo.lng`), or the same nested path given
twice (`lat:geo.lat,lng:geo.lat`).

Beyond simple renames (`--keys "old:new"`), `--keys` understands three placeholder
patterns for merging a run of similarly-named columns into one nested field --
handy for spreadsheets that spread one logical field across several columns
(`file_1`, `file_2`, `file_3`, ... or `sales_north`, `sales_south`, ...).

The source side captures whatever text follows a literal prefix: `[name]` captures it as
a number, `{name}` as text. The capture name only matters if it's referenced again on the
target side. *(Why brackets/braces work this way: see `0.2.0` in [Version History](#version-history).)*

**Plain array** -- merge sequential columns into one array of scalars, in column order:

```sh
spread-cli forms.csv -rj --keys "file_[n]:files[]"
```

`file_1=a.pdf, file_2=b.pdf, file_3=` (blank) becomes:

```json
{ "files": ["a.pdf", "b.pdf"] }
```

Blank cells are dropped, and an all-blank row still yields `files: []`, never an absent
key. Two shorthands for the common case where the capture name is never reused:
`file_*:files[]` (glob-style) and `file_[]:files[]` (empty brackets) both mean the same
as `file_[n]:files[]`.

**Dynamic-keyed object** -- turn each matching column into its own key inside a shared
nested object, using the captured text as the key:

```sh
spread-cli sales.csv -rj --keys "sales_{region}:sales.{region}"
```

`sales_north=120, sales_south=95` becomes:

```json
{ "sales": { "north": 120, "south": 95 } }
```

**Array of objects** -- turn each matching column into its own item in an array of
objects, with the captured value as one field and the cell's own value as another:

```sh
spread-cli sales.csv -rj --keys "sales_[year]:sales[].{year}{amount}"
```

`sales_2024=100, sales_2025=150` becomes:

```json
{ "sales": [{ "year": 2024, "amount": 100 }, { "year": 2025, "amount": 150 }] }
```

Swap `{amount}` for whatever field name you want (e.g. `{year}{value}`) -- the field
after the capture always holds the cell's own value, and takes its JSON type (number vs
text) from whichever bracket style the source pattern used for that capture.

All three forms mix freely with ordinary renames in the same comma-separated `--keys`
value, and work against xlsx/xlsm/xls/xlsb/ods just as well as CSV/TSV. They cover the
common cases by design -- anything more elaborate is better done by piping into
`jq`/`yq`, or with the `spreadsheet-to-json` library crate directly, which exposes the
full `KeySegment` tree these patterns compile down to.

### Suppressing columns <a id="suppressing-columns"></a>

Prefix a `--keys` entry with `-` to drop that column from the output entirely:

```sh
spread-cli people.csv -rj --keys "-colour"
```

The identifier after the `-` is matched case-insensitively against:

- the column's natural snake_cased header key by default (`-colour`)
- its A1 letter in `-A`/`--a1` mode (`-d` for column D)
- its column number in `-R`/`--r1c1` mode (`-4` for column 4 -- `-c4`/`-c04` also work)

An identifier that doesn't match any column is silently ignored, same as an unmatched
ordinary `--keys` override. Suppressions mix freely with everything else `--keys`
supports, comma-separated:

```sh
spread-cli people.csv -rjA --keys "-d,b:first_name"
```

### Skipping ranges and nested paths (`--skip-cols`) <a id="skipping-ranges-and-nested-paths"></a>

For dropping more than a column or two at once, `-K`/`--skip-cols` takes a
comma-separated list with three forms, none needing the leading `-` (everything here is
already a suppression):

```sh
spread-cli products.csv -rj -K "width..depth"           # every column from width to depth, inclusive
spread-cli products.csv -rj -K "width,depth"             # just those two -- keeps whatever's between them
```

The `a.b.c` form targets output that only exists once a `--keys` pattern has actually
nested something -- on its own, against a plain flat CSV, it's a no-op (there's nothing
at that path to remove yet):

```sh
# without -K: {"n": 1, "line1": "1 Road", "admin2": "Countyshire"} per address
# with -K "addresses.$.admin2": the same, minus "admin2", in every item
spread-cli contacts.csv -rj \
  --keys "line1_[n]:addresses[].{n}{line1},admin2_[n]:addresses[].{n}{admin2}" \
  -K "addresses.\$.admin2"
```

- **`start..end`** -- a range by position in the sheet's natural left-to-right column
  order (same natural-key/A1-letter/R1C1-number identifiers as plain suppression). A
  range given backwards (the end column actually comes before the start column in the
  sheet), or an endpoint that doesn't match any column, is a clear error -- not a silent
  guess at which way you meant it.
- **`name,name2`** -- independent single-column suppressions, equivalent to `--keys
  "-name,-name2"` without the `-` prefix per entry.
- **`a.b.c`** -- a dot-separated *output* path, removed from the row's final shape
  (after any `--keys` nesting) rather than resolved against a source column at all --
  this is the only form that can reach inside a `--keys`-built nested object or array.
  `$` as a path segment means "every item of this array" rather than a literal key
  (`addresses.$.admin2` drops `admin2` from each address, not the whole array). An
  unmatched or malformed nested path is silently ignored, same as an unmatched plain
  column name.

All three forms can be mixed in one comma-separated `-K` value.

### Splitting one column into an array <a id="splitting-one-column-into-an-array"></a>

The placeholder patterns above merge *several* columns into one nested field. For a
single column whose own cell text is already delimited (`"a.pdf|b.pdf"`,
`"north,south,east"`), use the array format instead -- `type[]` or `type[](separator)`
as the `|format` part of an ordinary `--keys` entry:

```sh
spread-cli people.csv -rj --keys "tags|text[]"          # split on "," (the default)
spread-cli people.csv -rj --keys "editors|text[](|)"     # split on "|" instead
spread-cli people.csv -rj --keys "scores|int[]"          # -> [85, 92, 78], real numbers
```

`type` is any of the usual format codes (`text`, `int`, `float`, ...), applied to each
element after splitting -- it must be one of those real codes, not the column/field
name (an unrecognized word here is silently treated the same as `text`, rather than
erroring, so a typo casting to `int[]` won't be caught). If you'd rather write it in a
more familiar, JS-like form, `.split(...)` works identically -- only the text between
`]` and `(` is ignored (that's where the function name goes), and a matching pair of
quotes around the separator is stripped if present:

```sh
spread-cli people.csv -rj --keys "editors|string[].split('|')"
```

All three forms above are equivalent. This is a single-column cast (`Format::Array` in
the underlying library), not a placeholder pattern -- no `[name]`/`{name}` capture is
involved, and it can be freely mixed with renames, other overrides, and placeholder
patterns in the same comma-separated `--keys` value.

### Splitting one column into named parts <a id="splitting-one-column-into-named-parts"></a>

Where each piece of a delimited cell means something different, name the pieces in
curly brackets and the cell becomes an object instead of a list:

```sh
spread-cli screens.csv -rj --keys "size|int{width height}(x)"
# "1024x800"  ->  "size": {"width": 1024, "height": 800}
```

The names are separated by spaces (a comma would end the `--keys` entry), and the
separator goes in parentheses as it does for an array (`,` if left out). The last name
takes whatever is left of the cell, so `"name|text{first last}( )"` reads
`Ada King Lovelace` as `first: "Ada"`, `last: "King Lovelace"`; a name with no piece
is `null`.

### Joining columns (`a+b`) <a id="joining-columns"></a>

Name several columns with `+` between them and they are read as one field. It is
written under the first column's name, or the name after `:`, and the other columns
leave the row.

```sh
# a date column and a time column as one datetime
spread-cli events.csv -rj --keys "day+start:starts_at|datetime"
# "19/07/2026", "2:30 PM"  ->  "starts_at": "2026-07-19T14:30:00.000Z"

# text columns, a space between them
spread-cli people.csv -rj --keys "first+middle+last:full_name"
# "Ada", "", "Lovelace"  ->  "full_name": "Ada Lovelace"
```

With a date or time format (`date`, `datetime`, `datetime-simple`, `time`, `hm`) the
two columns are a date and a time. Either may come first; a date with no time is
midnight, and a time with no date is `null`. With any other format, or none, the
cells are joined as text, and these words may follow the format, each after a `|`:

| Word | Effect |
|---|---|
| `join(, )` | what goes between the cells, in place of a space; `join()` joins them directly |
| `keep_empty` | empty cells keep their place (`Ada--Lovelace`), where normally they are left out |
| `keep_sources` | the joined columns stay in the row as fields of their own too |

```sh
spread-cli people.csv -rj --keys "last+first:person.name|text|join(, )"
# -> "person": {"name": "Lovelace, Ada"}
```

### Cells that are not of the column's type <a id="cells-that-are-not-of-the-columns-type"></a>

A column cast to a number or to true/false usually makes the best of what it finds.
Three words after the format (and after the default, if there is one) make it strict
instead: a cell has to be a number from end to end, and one that is not leaves the
field `null`, or at its default.

| Word | Effect |
|---|---|
| `strict` | text that is not a number is not read as one |
| `notes=key` | strict, and the text goes to the field `key` |
| `range=key` | strict, and two numbers (`200-400`, `200 to 400`) go to the field `key` as a list |

```sh
spread-cli towns.csv -rj --keys "population:pop|int|notes=pop_notes|range=pop_range"
# 2400      ->  {"pop": 2400}
# unknown   ->  {"pop": null, "pop_notes": "unknown"}
# 200-400   ->  {"pop": null, "pop_range": [200, 400]}
```

`notes` and `range` are only written in the rows that need them, and may be dotted
paths (`range=stats.pop_range`). With `notes` alone a range is kept there as text.
To leave out the rows that have no valid number, make the column strict and filter on
it:

```sh
spread-cli towns.csv -rj --keys "population:pop|int|strict" --filter "pop >= 0"
```

## Filtering rows (`--filter`) <a id="filtering-rows-filter"></a>

Drop rows that don't match a SQL-like boolean expression, evaluated against each row's
*final* keys -- after any `--keys` renames, not raw source columns:

```sh
spread-cli people.csv -rj --filter "age >= 18"
spread-cli people.csv -rj --filter "first_name ILIKE 'a%' and last_name ILIKE '%os'"
spread-cli people.csv -rj --filter "(first_name ILIKE 'a%' or last_name ILIKE '%os') and age >= 18"
spread-cli people.csv -rj --filter "country_code IN (us, gb, ca)"
spread-cli products.csv -rj --keys "size_{x}:size.{x}" --filter "size.width < 10"
```

- Comparisons: `=`, `!=`/`<>`, `>`, `>=`, `<`, `<=`, and `LIKE`/`ILIKE` (`ILIKE` is
  case-insensitive; `LIKE` isn't) with SQL `%` wildcards -- `'a%'` (starts with),
  `'%os'` (ends with), `'%foo%'` (contains), or no `%` at all (exact match). A `%` in
  the *middle* of a pattern (`'a%b'`) isn't supported and is a clear parse error, not a
  silently wrong match -- that needs two independent anchors, which no single check can
  express in one pass; split it into two `AND`-ed conditions instead.
- `IN (...)`/`NOT IN (...)` -- the field's own value equals (or doesn't equal) one of
  a comma-separated list. `ANY (...)`/`NOT ANY (...)` is the array counterpart -- the
  field's own value must itself be an array (e.g. from `--keys "tags|text[]"`) sharing
  at least one element with the list; a plain scalar field never satisfies `ANY`, that's
  what `IN` is for. Quotes around a list/comparison value are only *required* to group
  a value containing a space or comma into one token -- `IN (us, gb, ca)` and
  `IN ('us', 'gb', 'ca')` are equivalent, and a bare value can't reuse a reserved word
  (`and`, `in`, `like`, ...) as a literal, same as an unquoted identifier in SQL.
- A field reference can be a dot-path into an object `--keys` has already nested
  (`size.width`, once `--keys "size_{x}:size.{x}"` has mapped `size_width`/`size_height`
  columns into one `size` object), not just a top-level key. It can't reach inside an
  *array* of nested objects, though (`addresses.admin2` where `addresses` is itself an
  array) -- matching through an array raises a real "does the row match if *any* item
  satisfies it, or only if *all* do" question that's deliberately left open rather than
  decided silently.
- Combine with `AND`/`OR` (case-insensitive) -- `AND` binds tighter than `OR`, override
  with parentheses -- and negate with `NOT` (`NOT (age >= 18)`, or `first_name NOT ILIKE
  'a%'`).
- A row missing the field entirely does not match (a filter never treats an absent
  column as satisfying the condition). Filtering always runs before `-X`/
  `--exclude-null`, so a field `-X` would otherwise strip is still present with its
  real value when a filter checks it.
- `-m`/`--max` still bounds how many rows are *read*, not how many *pass* the filter --
  a heavily-filtered file can return fewer than `-m` rows even when more matches exist
  further down, since `--max` is a scan cap for quick structural preview of large files,
  not a "collect N matching rows" limit. To cap the number of *matching* rows instead,
  use `-L`/`--limit`:

  ```sh
  spread-cli people.csv -rj --filter "age >= 18" --limit 20
  ```

  Scanning stops as soon as `--limit` rows have matched, rather than reading the whole
  file first -- the two flags compose when both are set, whichever bound is hit first
  wins (e.g. `-m 100 --limit 20` stops at 20 matches, or after 100 rows scanned,
  whichever comes first).

## Options

- ```path``` Local path to the source spreadsheet or CSV/TSV file
- ```-s, --sheet``` case-insensitive sheet name, ignoring spaces/punctuation; falls back to the first sheet if unmatched
- ```-n, --number``` sheet number, 1-based (`-n 1` is the first sheet)
- ```-k, --keys```: comma-separated column overrides, `source_key[:new_key][|format[|default]]`. `source_key` matches the column's natural (auto-detected, snake_cased) header name wherever it actually is, so you only list the columns you want to change -- an unmatched `source_key` is silently ignored. Omit `:new_key` to change only the format/default:
  - `--keys "start_date|date"` casts `start_date` to a date, keeping its name
  - `--keys "start_date:start|date"` also renames it to `start`
  - `--keys "start_date:start|date,total_price:total"` mixes several overrides in one value
  - `--keys "lat:geo.lat,lng:geo.lng"` nests both columns into one `geo` object -- see [Nesting named columns](#nesting-named-columns)
  - `--keys "day+start:starts_at|datetime"` reads a date column and a time column as one datetime, and `--keys "first+last:name"` joins text columns -- see [Joining columns](#joining-columns)
  - `--keys "size|int{width height}(x)"` splits `1024x800` into `{"width": 1024, "height": 800}` -- see [Splitting one column into named parts](#splitting-one-column-into-named-parts)
  - `--keys "population|int|notes=pop_notes"` keeps text found in a number column in a field of its own -- see [Cells that are not of the column's type](#cells-that-are-not-of-the-columns-type)
  - `date` is one of several date/time format codes -- see the table under `--date-only` below
  - three words in square brackets go where the default goes, to say what happens where the column is empty in place of filling it:
    - `--keys "max_height|d6|[skip]"` leaves `max_height` out of any row where the cell is not a number, and `--keys "code|text|[skip]"` leaves `code` out where it is blank. What counts as empty follows the format: a number or true/false column is empty unless the cell reads as one (blank and `n/a` alike), any other column when it is null or an empty string
    - `--keys "status|truthy|[omit]"` leaves the column out only where it is null after conversion; an empty string stays
    - `--keys "code|text|[keep]"` writes the column even where `-X` would drop it. A column cast to `text` is always a string, `""` when the cell is empty, so `row.code.length` is safe to read
  - `--keys "-colour"` (leading `-`) suppresses that column instead -- see [Suppressing columns](#suppressing-columns)
  - `--keys "file_[n]:files[]"` and two other placeholder patterns merge several columns into nested output -- see [Column mapping patterns](#column-mapping-patterns-keys)
  - `--keys "tags|text[](,)"` splits *one* column's delimited text into a JSON array instead -- see [Splitting one column into an array](#splitting-one-column-into-an-array)
- ```-f, --filter``` drops rows that don't match a SQL-like boolean expression against the row's final keys, e.g. `"age >= 18 and name ILIKE 'a%'"` -- see [Filtering rows](#filtering-rows-filter)
- ```-K, --skip-cols``` drops a range (`"width..depth"`), list (`"width,depth"`), or nested output path (`"addresses.$.admin2"`) of columns from output -- see [Skipping ranges and nested paths](#skipping-ranges-and-nested-paths)
- ```-X, --exclude-null``` drops any key whose cell was empty from output, recursively through nested objects/arrays too, instead of emitting `"key": null` or `"key": ""`. Empty means JSON `null` (nothing there, or nothing readable as the column's format) or an empty string, which is what an empty text cell reads as. A string of spaces, `0` and `false` are values and are kept. A column given a default in `--keys`, or marked `[keep]` there, is always written.
- ```-m, --max``` max rows *scanned* per sheet (with `-p`, every sheet gets its own cap, default 10) -- keeps scanning up to this many rows regardless of how many pass `--filter`; suits pagination/batch processing. See [Filtering rows](#filtering-rows-filter) for how this differs from `-L`/`--limit`.
- ```-L, --limit``` max *matching* rows returned -- distinct from `-m`/`--max` above; scanning stops as soon as this many rows have matched (or, with no `--filter`, simply been read). See [Filtering rows](#filtering-rows-filter).
- ```-t, --top``` header row number, 1-based, if the header isn't on the first row -- e.g. a title/notes row above it. If not given, the header row is detected automatically.
- ```-b, --body-start``` row number, 1-based, where the real data begins, if there's a gap below the header (a blank or subtitle row). Rows between the header and this one are skipped entirely. Defaults to immediately after the header row.
  - Example: title in row 1, notes in row 2, real header in row 3, blank row before data in row 5 -- `-t 3 -b 5` skips straight past the blank row instead of capturing it as a row of nulls.
  - With `-j`, the row indices *actually used* -- whether from `-t`/`-b` or auto-detection -- come back as `header_row`/`body_start` (1-based) and `header_index`/`body_index` (0-based).
- ```--omit-header``` treat the file as having no header row at all; columns get fallback letter names (`a`, `b`, `c`, ... or `c01`, `c02`, ... with `--colstyle`) instead. Pair with `--keys` to give them real names: `--omit-header --keys "a:region,b:team_size,c:revenue"`.
- ```-c, --colstyle```: fallback column-naming style for columns with no usable header, `style[:mode]` -- `style` is `a1` (letters) or `c01`/`r1`/`r1c1` (zero-padded numbers); `mode` is `all` (every column, the default) or anything else to only fill in columns lacking a real header.
- ```-A, --a1``` (alias `-a`) shorthand for `-c a1` -- every column named by its A1 letter instead of its header. Ignored if `--colstyle`/`-c` is also given explicitly.
- ```-R, --r1c1``` shorthand for `-c c01` -- every column named by its zero-padded number (`c01`, `c02`, ...) instead of its header. Ignored if `--colstyle`/`-c` is also given explicitly.
- ```-d, --deferred``` For large files: streams rows to a `.jsonl` file instead of holding them all in memory. Defaults to a random-UUID filename under `EXPORT_FILE_DIRECTORY` (a `.env` variable, default `./`) -- name it yourself with `-o`. On Linux/macOS this runs as a detached background process and returns immediately; check `{path}.log` afterward to confirm it finished. On Windows it runs in-process instead, still memory-efficient, just blocking.
- ```-o, --output``` export file path for `-d`; has no effect without it
- ```-j, --json``` outputs one valid, indented JSON object/array for the full result -- see [Quick start](#quick-start) above for why this matters
- ```-p, --preview``` reads every worksheet (up to `-m` rows each, default 10) instead of just one -- `-s`/`-n` are ignored in this mode. Field names for every sheet come back in a top-level `columns` map; each sheet's rows live under `data`.
- ```-x, --overview``` drops row values, keeping only structure -- sheet names, row counts, field names. Combine with `-p` (`-xp`) for a full-workbook overview with no cell data at all: `columns` (fields per sheet) and `row_counts` (rows per sheet), no `data` key. See [Quick start](#quick-start). (Also accepted as `--exclude-cells`, its original name.)
- ```-r, --rows``` just the data rows, as a JSON array, no metadata wrapper
- ```-l, --lines``` JSON Lines: one compact object per row, no wrapper -- implies `-r`
- ```--euro-number-format```: parse decimal commas when converting formatted strings to numbers
- ```--date-only``` / ```--time-only``` / ```--hm-only``` / ```--simple``` format every date-time column as a date, a time, hours:minutes, or a full date-time without milliseconds/`Z`, respectively. Each wins over the ones after it if more than one is set (`--date-only` > `--time-only` > `--hm-only` > `--simple`).

  To override just one column instead, use `--keys "col|<code>"`:

  | code | example output | notes |
  | --- | --- | --- |
  | `dt`/`datetime` (or no override) | `2026-07-19T19:58:45.000Z` | the default: full precision, JS/JSON-interop-friendly |
  | `ds`/`simple` | `2026-07-19T19:58:45` | full date-time, no milliseconds or `Z` |
  | `da`/`date` | `2026-07-19` | date only |
  | `ti`/`time` | `19:58:45` | time only, with seconds |
  | `hm` | `19:58` | time only, hours and minutes |

  e.g. `--keys "logged_at|hm"` renders just `logged_at` as `"19:58"`, leaving every other date-time column at its row-wide default. `time`/`hm` also recover a time from a plain decimal number or dot-separated string (`12.3` -> `12:30`) and a trailing AM/PM marker (`"2:30pm"` -> `14:30`) -- only ever under an explicit `|time`/`|hm` override, never automatically. Hours are not capped at 24, since a "time" column is just as often a duration as a time-of-day. *(Full mechanics and edge cases: see `spreadsheet-to-json`'s [Version History](https://github.com/neilg63/spreadsheet_to_json#version-history), `0.3.0` and `0.3.2`.)*

  Other date/time transformations (reformatting, day-of-week, timezone conversion) are out of scope here -- pipe into `jq`/`yq`, or use the `spreadsheet-to-json` library crate directly for Rust code.
- ```--debug``` prints processing time and extra diagnostic detail on error, to stderr when the main output is JSON (so it never corrupts a piped result)

0-based equivalents, for scripts that already track rows/sheets by index rather than the friendly 1-based numbers above: `--index` (= `-n`), `--header-index` (= `-t`), `--body-index` (= `-b`).

## Using with `jq` (or `yq`)

For piping, reach for `-r` (rows as a JSON array) or `-l` (JSON Lines) -- both are always valid JSON/JSONL on their own, with or without `-j`. `yq` handles either shape just as well as `jq` -- including line-delimited JSON, which it reads as a stream of separate documents:

```sh
spread-cli sales.xlsx -l | yq -p json 'select(.price > 10)'
```

`-j`/`--json` only matters for the *full* result (no `-r`/`-l`) -- see [Quick start](#quick-start) -- and it's a pure formatting flag there too: indentation, not content.

```sh
# full result: metadata (extension, sheets, row_count, fields, ...) + data together
spread-cli sales.xlsx -j | jq '.data[] | {sku, price}'
spread-cli sales.xlsx -j | jq 'del(.data)'                    # metadata only

# -p: every worksheet, not just the selected one -- field names per sheet in "columns",
# rows come back per-sheet under "data"
spread-cli workbook.xlsx -pj | jq '.columns'                     # {sheet: [fields], ...}
spread-cli workbook.xlsx -pj | jq '.data[] | {sheet, row_count}' # every sheet's row count

# -xpj: a quick structural overview of every worksheet, no row data at all -- just sheet
# names, field names ("columns"), and row counts ("row_counts"). Ideal for large
# multi-sheet files (e.g. statistics-agency spreadsheets) before deciding what to pull.
spread-cli workbook.xlsx -xpj | jq '.columns'
spread-cli workbook.xlsx -xpj | jq '.row_counts'

# -rj (or -r --json): just the rows, as a pretty-printed array, no metadata wrapper
spread-cli sales.xlsx -rj | jq '.[] | select(.price > 10)'
spread-cli sales.xlsx -rj -k "date|date" | jq '.[] | { date, total_price }'
spread-cli sales.xlsx -rj | jq -r '.[] | [.sku, .name, .price] | @csv'

# -l: plain JSON Lines, one row per line -- best for streaming into another
# NDJSON-consuming tool, or very large files (jq/yq consume it line-by-line rather than
# waiting for one big array to finish printing)
spread-cli sales.xlsx -l | jq -c 'select(.price > 10)'
spread-cli sales.xlsx -l | jq -c '{sku, total: (.price * .qty)}' > sales.ndjson
spread-cli sales.xlsx -l | yq -p json -o yaml 'select(.price > 10)'
```

## Version History <a id="version-history"></a>

Pre-0.2.0 releases aren't individually catalogued here; see the git history.

- **0.2.0** Added the three `--keys` placeholder-pattern DSLs and column suppression -- see [Column mapping patterns](#column-mapping-patterns-keys) above. `[name]`/`{name}` in the source pattern deliberately mirror JSON's own shape as a mnemonic: square brackets (arrays are index-ordered) type the capture as a number, curly braces (objects are string-keyed) as text. Added `-A`/`--a1` (alias `-a`) and `-R`/`--r1c1` as shorthands for `--colstyle a1`/`c01`; both take the capital consistently -- `-R` since `-r` already means `--rows`, and `-A` to match it -- and `-R` is often the more practical choice for very wide sheets once A1 letters run past `z` into double letters. Added `-X`/`--exclude-null`, wiring the library's `RowOptionSet::omit_null_values` through to the CLI.