Skip to content
Docs

CSV and JSON Data Export

CSV and JSON data export reaches every result surface in the workbench — the edit-db grid, the SQL console, and the report runner — all backed by one shared utility (examples/edit-db/src/lib/export.ts). There is no second export implementation in the repo.

  • Full result set, not the visible page. A grid export with an active column filter and sort pages through the fetcher and exports every matching row across all pages — the exported row count equals the server’s total count for that filter.
  • RFC4180-correct CSV. A value containing a comma, a double quote, or a newline is quoted exactly per the spec, and NULL is emitted distinguishably from the empty string.
  • Excel BOM option. With the BOM option enabled, the UTF-8 byte-order mark is the first bytes of the file.
  • Formula-injection guard (CWE-1236). A text value that starts with =, +, -, @, tab, or carriage return gets a leading apostrophe so a spreadsheet opens it as text instead of running it as a formula. Numeric column values arrive typed and are left alone, so a negative number stays a number. That exemption is a typeof value === 'string' test, so it depends on the wire type: Int, BigInt and Decimal serialize as JSON numbers today (ExactNumericScalars adds no custom Serialize, and the client parses the response with plain JSON.parse), so a -5 cell is a JS number. If a numeric scalar is ever serialized as a decimal string — the input direction already accepts one — every negative value in that column starts getting an apostrophe. Change the guard with the serializer, not after a bug report.
  • BigInt-safe JSON. A BigInt primary-key value round-trips without precision loss (carried as a string, never a Number-coerced value), and dates keep a documented, stable format.
  • Row cap with confirm. Exporting above the row cap prompts for confirmation first; cancelling mid-export stops paging and leaves no partial file.

In the browser, export downloads a Blob via a transient anchor. On the desktop shell, the editor’s exports (grid toolbar and the table list’s Download actions) route through the native save-file bridge: the OS save dialog picks the destination, a cancelled dialog writes nothing, and the shell reports the saved path. Hosts embedding the editor elsewhere can supply their own saver via <Editor saveFile={...}>.