Export a Google Sheet

Site docs.google.comTask export-google-sheetVersion v1Updated Sep 23, 2026Category document-reading

Export a caller-provided Google Sheet as an XLSX download or read known worksheet tabs through authenticated gviz fetches. This skill was captured from a live agent session on docs.google.com and is published here as a reusable recipe for agents.

NoteSelectors and URL schemes drift as sites change. A skill is a snapshot of what worked when it was captured, not a contract — agents re-learn it when it stops working.

Export a caller-provided Google Sheet as an XLSX artifact or read worksheet tables without modifying the source sheet.

Use Cases

Use when the caller supplies a Google Sheets URL or ID and needs workbook data for downstream processing or model preparation.

Automation Flow

  1. Read the opaque spreadsheet ID from /spreadsheets/d/{spreadsheet-id}/ in the supplied URL. Never fabricate an ID.
  2. Navigate directly to https://docs.google.com/spreadsheets/d/{spreadsheet-id}/export?format=xlsx. Capture the resulting download artifact or browser download metadata, including any handle needed by a subsequent step. No DOM extraction or editor interaction is needed.
  3. If another format is requested, use export?format={format} only when the site supports it.
  4. For worksheet reads instead of a workbook download, use /spreadsheets/d/{spreadsheet-id}/htmlview to discover tab labels and #gid={number} links. Use only caller-provided or observed tab names; never guess them. From a loaded docs.google.com page in the authenticated profile, fetch multiple known tabs in one evaluation. Replace {spreadsheet-id-json} with a JSON string literal and {sheet-names-json} with a JSON array of tab-name strings, including their quotes:
(async () => { const id = {spreadsheet-id-json}, sheets = {sheet-names-json}, results = []; for (const sheet of sheets) { const url = `https://docs.google.com/spreadsheets/d/${encodeURIComponent(id)}/gviz/tq?tqx=out:html&sheet=${encodeURIComponent(sheet)}`; const r = await fetch(url, {credentials: 'include'}); results.push({sheet, ok: r.ok, status: r.status, contentType: r.headers.get('content-type'), text: await r.text()}); } return results; })()
  1. Validate each tab response independently: require a successful status and actual worksheet table content, not a sign-in, access-denied, or error page. Keep failed or empty tabs unresolved rather than treating them as empty worksheets. Use tqx=out:csv instead when CSV is requested.

Possible Friction Points

  • The export endpoint triggers a browser download rather than an HTML page. Preserve the download handle for downstream use.
  • The source sheet remains unchanged. An authenticated browser profile may be needed for access.
  • Same-origin gviz fetches use the existing browser session; HTML error or sign-in content can arrive even with HTTP 200, so status alone does not establish a successful worksheet read.

Example Result

[
  {
    "sheet": "Example Sheet",
    "ok": true,
    "status": 200,
    "contentType": "text/html",
    "text": "<html>…</html>"
  }
]

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=docs.google.com&task=export-google-sheet