Use this script to query data from your Xentral system directly in Google Sheets.
You can use two simple functions in your sheet:
=XENTRAL_QUERY("SELECT * FROM ...")=XENTRAL_REPORT(report-id)
Before you start, you’ll need a Personal Access Token (PAT) from your Xentral account. To generate one:
- Log in to your Xentral instance.
- Go to "Kontoeinstellungen" (Account Settings).
- Navigate to the "Developer Einstellungen" tab.
- Click on "Personal Access Token".
- Generate a new token and copy it – you’ll need it in Step 4 below.
Create a new or open an existing Google Sheet where you want to use Xentral data.
In your sheet, click:
Extensions → Apps Script
This will open a new tab with the Google Apps Script editor.
Head over to our GitHub and copy the code from the file: 🔗 Code.js
Remove the existing code:
It must be completely empty:
Now paste the entire script into the Apps Script editor.
At the top of the script, simply adjust these two lines with your Xentral instance and the Personal Access Token (PAT):
const XENTRAL_URL = 'https://{your_instance}.xentral.biz' // Your Xentral Instance
const PAT = '' // Your Personal Access Token in between ''For example:
const XENTRAL_URL = 'https://abc.xentral.biz';
const PAT = 'abc123yourPATtokenhere';💡 Don't have a PAT yet? See the "Prerequisites" section above to get one.
Click the 💾 Save icon (or press Ctrl + S).
You can name the project something like Xentral Integration.
- Hit the
▶️ Run/Ausführen button to execute a test query - Google will ask for authorization - approve it (you may need to click "Advanced" → "Go to project name").
Now you're ready to use Xentral data like a pro!
Use the XENTRAL_QUERY function:
=XENTRAL_QUERY("SELECT sales_order_id, date, net_revenue FROM sales_orders LIMIT 5")
Returns the net revenue per sales_order_id and date
If you have a report saved in Xentral (with an ID), use:
=XENTRAL_REPORT(68453)
This pulls the result of a saved report with ID
68453.
📌 Note: If you open the report in Xentral, you can find the ID in the URL ...&activeReport=71088
CSV or text and the delimiter to , so that GSheet interprets the data correctly.
-
Incorrect values in GSheet for XENTRAL_REPORT?
→ The export type needs to be set toCSVortextand the delimiter to,so that GSheet interprets the data correctly. -
"ReferenceError: XENTRAL_URL is not defined"
→ Make sure you addedconst XENTRAL_URL = ...at the top of the script. -
"Authorization Required"
→ You need to run and authorize the script once manually. -
Nothing shows up in the sheet?
→ Double-check your SQL/report ID and PAT, and confirm the script has the correct instance URL.






