# QuickBooks Desktop in Google Sheets

There are two ways to get QuickBooks Desktop data from Desktop Books into Google Sheets. The Cellfetch add-on reads the API on a schedule and builds the report tabs for you, with no code. Or an Apps Script you own calls the API with your key. Either way the sheet is as fresh as the last Web Connector check-in.

## Which to use

| | Cellfetch add-on | Your own Apps Script |
| --- | --- | --- |
| Setup | About 2 minutes after the company file is connected | About 20 minutes if you're comfortable with Apps Script |
| Report tabs | Built on the first run: invoices due, customer balances, A/R aging, profit and loss, job costing | Whatever you build |
| Schedule | Picked in the sidebar | A time-driven trigger you set up |
| Cost | A separate Cellfetch subscription ([pricing](/pricing) shows the two together) | Only Desktop Books |

## With the Cellfetch add-on

1. In Desktop Books, open **API keys**. Under **Create a key**, label it after the sheet ("Client A month-end sheet"), pick the company file and click **Create key**. Copy the key.
2. In the Google Sheet: **Extensions > Add-ons > Get add-ons**, search Cellfetch and install it. Then **Extensions > Cellfetch > Start**.
3. Pick **QuickBooks Desktop (with Desktop Books)**, paste the key and choose the company file from the list Cellfetch shows.
4. Pick what to read and a schedule, then click **Run now**.

| Pick | The data tab | The report tab built on the first run |
| --- | --- | --- |
| Invoices | Every invoice with balance, due date and days overdue | Open and overdue balance, open balance by customer, the overdue list, invoiced by month |
| Customers and jobs | Customers and jobs with balances and contact details | Owed by customers, largest balances, jobs by status |
| A/R aging | QuickBooks' A/R aging summary as of today | Open receivables, over 90 days, open by customer |
| Profit and loss | QuickBooks' standard profit and loss, this year to date | Income, expenses, net income, expenses by account |
| Job profitability | QuickBooks' job profitability summary, this year to date | Revenue and margin on jobs, margin by job, lowest margins |

Report tabs are formulas over the data tab, so your own formulas next to them keep working when the rows change. Cellfetch's QuickBooks Desktop page shows the fields and a sample report tab.

### What a scheduled refresh does with a no-copy file

Cellfetch asks with `if_queued=error`, so a file in [no-copy mode](/docs/no-copy-mode) answers `409 no_copy_kept` at once. The sheet keeps its last rows and the run log says the file keeps no copy, instead of emptying the tab. For Sheets, keep a copy.

## With your own Apps Script

`IMPORTDATA` can't do this: Google's function takes only a URL, and the API needs a key in a header, which never belongs in a URL. Apps Script's `UrlFetchApp.fetch` can send the header. Keep the key in Script Properties (**Project Settings > Script Properties**), not in a cell, where anyone with view access could read it.

This script reads every open invoice, page by page, into a tab called Open invoices:

```javascript
function refreshInvoices() {
  const key = PropertiesService.getScriptProperties().getProperty("DESKTOP_BOOKS_KEY");
  const base = "https://desktop-app.greatwork.company/v1/files/file_8f2c41/invoices";
  const rows = [];
  let columns = null;
  let cursor = null;
  do {
    const url = base + "?status=open&flat=1&limit=500" + (cursor ? "&cursor=" + encodeURIComponent(cursor) : "");
    const res = UrlFetchApp.fetch(url, { headers: { Authorization: "Bearer " + key }, muteHttpExceptions: true });
    let body;
    try {
      body = JSON.parse(res.getContentText());
    } catch (e) {
      throw new Error("Desktop Books answered " + res.getResponseCode() + " without JSON. Try again in a few minutes.");
    }
    if (res.getResponseCode() !== 200) throw new Error(body.error ? body.error.message : body.message);
    columns = columns || body.columns;
    body.data.forEach((r) => rows.push(columns.map((c) => safe(r[c]))));
    cursor = body.next_cursor;
  } while (cursor);
  const book = SpreadsheetApp.getActive();
  const sheet = book.getSheetByName("Open invoices") || book.insertSheet("Open invoices");
  sheet.clearContents();
  sheet.getRange(1, 1, 1, columns.length).setValues([columns]);
  if (rows.length) sheet.getRange(2, 1, rows.length, columns.length).setValues(rows);
}

// A memo or name that starts with = + - @, a tab or a line break would otherwise run as a formula.
function safe(v) {
  if (v === null || v === undefined) return "";
  return typeof v === "string" && /^[=+\-@\t\r\n]/.test(v) ? "'" + v : v;
}
```

`flat=1` returns one flat row per record with a `columns` list, the same shape as the CSV. A non-200 answer stops the script with the API's own message, which covers a queued read on a no-copy file too. To run it on a schedule, add a time-driven trigger under **Triggers**; matching it to the file's check-in interval (60 minutes by default) is enough, since polling more often returns the same data.

## Freshness

Both ways read what the last check-in brought. The `as_of` field says which check-in that was; if it's older than you expect, see [Freshness and sync](/docs/freshness-and-sync). For keys and scopes, see [Authentication](/docs/authentication).

Checked on November 29, 2026 against Google's [IMPORTDATA help page](https://support.google.com/docs/answer/3093335).

Previous: [Limits](/docs/limits) | Next: [Excel and Power Query](/docs/excel-power-query)
