Import & export
Four ways in, four ways out. All of them converge on the same grid, so an imported table is indistinguishable from a typed one the moment it lands.
What is supported
| Format | Import | Export |
|---|---|---|
| CSV / TSV, delimiter sniffed | ✓ | ✓ |
| JSON — a grid, or a list of records | ✓ | ✓ |
HTML — a pasted <table> | ✓ | ✓ |
| XLSX / XLS / ODS | Pro | Pro |
Pasting, which is usually the answer
Before reaching for a file: copy a block of cells out of Excel, Numbers or Google Sheets and paste it into any cell of the grid. Legs works out the delimiter, expands the table to fit and fills from that cell. No file, no upload, no round trip.
Replacing a table from a file
On a table's edit screen, Replace from a file in the sidebar. The grid is replaced wholesale and the table is marked as imported.
Delimiters are sniffed rather than asked for, by looking at which candidate produces the most consistent row width across the first few lines — a comma inside prose loses to a tab that separates columns. Encodings that are not UTF-8 are converted, and a byte-order mark is stripped.
JSON, in two shapes
A grid:
[["Plan", "Price"], ["Basic", "$10.00"]]
Or a list of records, where the keys of the first object become the header row:
[
{ "name": "Ada", "born": "1815" },
{ "name": "Alan", "born": "1912" }
]
The JSON export is the round-trip format: it carries the options, the merges and the column settings, so a table can be moved between sites whole. CSV is deliberately lossy — there is nowhere in a CSV to put a merged cell — and exports as text with markup stripped.
HTML
Paste or upload markup containing a table — a page saved from a browser, a paste from Word or Docs, a competitor's price list — and Legs parses the first <table> it finds. colspan and rowspan become real merges rather than being flattened, which means the grid is laid out into a rectangle first: a spanned cell occupies positions its own row never mentions. <thead> and <tfoot> become header and footer row counts.
XLSX (Pro)
Needs PhpSpreadsheet, which Legs suggests rather than requires — it is a ~10 MB dependency, and a free install that only ever pastes from Google Sheets should not pay for it:
composer require phpoffice/phpspreadsheet
Until it is installed, the XLSX option tells you exactly that command rather than saying “not supported”. On export, every cell is written as an explicit string: an author's 007 or 1-2 is a label, and a spreadsheet left to guess turns both into something else.
From the command line
php craft legs/tables/export price-list --format=json > prices.json
php craft legs/tables/import price-list ./prices.csv