Skip to content

Import and export files with the spreadsheet API

Import CSV or XLSX into one sheet and export an A1 range as a file. The server saves each job before returning 202. Only succeeded confirms that the import was written or the export is ready.

Use the sheet ID from GET /workbook. Import requires Edit cells, and export requires Read.

Method Inputs
POST /sheets/{sheetId}/imports Query format=csv or xlsx, range=A1 or a rectangle, header Idempotency-Key, raw file bytes, optional If-Match: "42"
POST /sheets/{sheetId}/exports JSON format, range, idempotencyKey, optional revision
GET /jobs/{jobId} Job ID from the 202 response
GET /jobs/{jobId}/file ID of a successful export

Poll the job about every two seconds. queued and running are pending states. A successful result has revision, range, and cells for imports or size in bytes for exports. A failed job has an error code.

  • CSV defaults to UTF-8 and comma. Choose encoding=windows-1251 or gb18030 and delimiter=comma, semicolon, tab, or pipe. Spreadsheet number and date parsing applies. Formula-like input text remains text.
  • XLSX takes one visible sheet. formulas=preserve requires range=A1 and a write key for all sheets. It supports references within the incoming rectangle and the basic functions SUM, AVERAGE, MIN, MAX, COUNT, COUNTA, IF, IFERROR, AND, OR, NOT, ABS, and ROUND. External references and unsupported formulas fail the job. Values and supported formulas are imported. Styles, images, names and validation rules are omitted.
  • Exports contain computed values. CSV is UTF-8 with commas and prefixes formula-like text with an apostrophe. XLSX stores that text unchanged as a string. Formulas, links and images are excluded.
  • Up to 1 MiB uploaded, 8 MiB expanded XLSX, 256 ZIP entries, 10,000 written positions, and 50,000 positions or 8 MiB exported. Import commits in one revision and honors protection, validation and workbook limits.
  • Jobs expire after 24 hours. The original key must still have access. Pending limits are 2 per key, 8 per organization, and 64 overall. Retained limits are 24, 64, and 256 respectively. Up to two jobs run at once across the server pool.

Replay the same bytes, options, revision condition and idempotency key to find the current state after a lost submission response. Use a new key for a changed request. 409 or 412 revision_conflict means reread the revision. If the revision changed after 202, the job fails and includes the current revision in result. For 409 job_not_ready, check status. Follow Retry-After on 429 or 503.