This Google Sheets script fetches data from a Supabase database and writes the selected headers and data to the active sheet. The script first clears the sheet, writes the headers, then fetches the data from the Supabase API, and finally writes the data to the sheet. It is optimized and has anonymized variables for public use.
- Create a new Google Sheet or open an existing one.
- Click on "Extensions" in the menu, then select "Apps Script." (If you don't see "Extensions," click on "Tools" and then "Script editor.")
- In the Apps Script editor, replace the default
Code.gs
content with the content ofsupabase_to_google_sheets.gs
. - Replace the
SUPABASE_URL
andSUPABASE_ANON_KEY
variables with your actual Supabase URL and anon key. - Adjust the
SELECTED_HEADERS
arrays according to your needs. - Save the script by clicking on the floppy disk icon or pressing
Ctrl+S
(Cmd+S
on Mac). - To run the script, go to the "Select function" dropdown in the toolbar, choose
mainFunction
, and click the "Run" button (the triangle icon). - Grant the necessary permissions when prompted.
- The script will clear the active sheet and fetch data from the Supabase API, then write the selected headers and data to the sheet.
Remember to save your changes before running the script. You can customize the SELECTED_HEADERS
arrays as needed, and you can modify the script's behavior if necessary.