convert_to_block
Turn an existing spreadsheet table into a named block with fields and row keys, keeping values intact, so formulas can reference it by name instead of cell coordinates.
Instructions
Turn a table that already exists in ordinary cells into a block, in place, without touching its values.
This is how you adopt a workbook someone hands you. create_block is for new tables and refuses to write over existing data; this one takes the data as it stands and gives it a name, fields and row keys, so you can address it as (block, row_key, field) and reference it from formulas by name instead of by coordinate.
Give position and the counts for the DATA only, leaving out any header row. Field names come from the header row — pass header_row, or leave it out and the row directly above the data is used when it looks like titles. fields states them outright instead.
The row key is inferred: the first column whose values are all present and all different. Pass key_field to choose. Whatever is inferred is reported back, so check it — the key is how formulas and later edits name a row.
Converting is a one-time cost: the block and its schema survive saving and reloading, and afterwards the region behaves exactly like one created as a block.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Ref name for the new block — BLOCKREF's first argument. Must be unique. | |
| sheet | Yes | Sheet the table is on. | |
| fields | No | Field names, when there is no header row. Length must equal col_count. | |
| position | Yes | Top-left cell of the data, excluding the header row. | |
| col_count | Yes | Number of columns. | |
| key_field | No | Which field identifies a row. Omit and the first column whose values are all present and all different is used. | |
| row_count | Yes | Number of data rows. | |
| header_row | No | Row holding the column titles; field names are read from it. Omit it and the row directly above `position` is used when it looks like a header — all text, over data that is not. |