Example Site
To see a live example, click here.
The Google Sheets Integration package provides you with the ability to easily monitor and manage data stored in a Google spreadsheet from a Wix site. You can perform the following actions with this package:
To see an example site that demonstrates how to use the package, click here.
Before using the package, set up the following:
velo-spreadsheet-credentials
. Store the contents of the downloaded file in the secret.https://docs.google.com/spreadsheets/d/{YOUR_SHEET_ID}/edit#gid=0
. https://docs.google.com/spreadsheets/d/1Ui3ha9jLRW4mTYBUimt9ooTRyS301SAKpMv_2zYx0n0/edit#gid=0
, the value of your sheet ID is: 1Ui3ha9jLRW4mTYBUimt9ooTRyS301SAKpMv_2zYx0n0
.sheetId
.The following backend files are included in the package. Note that only exported functions that you can use in your site are listed here.
The code in this file contains functions for getting, appending, updating, and clearing data from a Google spreadsheet.
To use the functions below in your backend code, import them with the following syntax:
The file contains the following functions:
getValues()
Queries the spreadsheet for a specified range of cells and returns one or more arrays containing the values stored in those cells.
appendValues()
Appends the specified values to the spreadsheet either in the current tab in a new row after the last current row, or in a specific location. To append the specified values to a specific location in the spreadsheet, add the optional range
parameter.
updateValues()
Updates the data in the specified range and dimension of the spreadsheet with the values provided.
clearValues()
Clears the data in the specified range of the spreadsheet.
sheetId
: ID of the spreadsheet you want to use. You can find the ID string in the URL of your spreadsheet link: https://docs.google.com/spreadsheets/d/{YOUR_SHEET_ID}/edit#gid=0
.values
: Array of strings you want to insert into the spreadsheet.range
: The location in the spreadsheet you want to select. String must be in ‘A1’ notation. For example, to select cells A1:B1 in the current tab, use ‘A1:B1’
. To select cells A1:B1 in Tab2 of the spreadsheet, add the tab name before the cells and separate it with an exclamation mark. For example, ‘Tab2!A1:B1’
.dimension
: The type of your range. String is either ‘ROWS’
or ‘COLUMNS’
.This section demonstrates how you can work with the package, and the different options for using the package functions. There are 4 main use cases you can implement with this package:
The following describes how you can use this package to get the data from the first row (A1:B1
) of your spreadsheet. If you want to get data from a different location in your spreadsheet, simply pass a different range
to the getValuesWrapper()
function located in the getValuesFromSheet()
function in your page code.
Open your Google spreadsheet and place some data in the first row (A1:B1
):
To use the getValues()
function in your page code, add a web module to your backend. We’ll call ours googlesheet-wrapper.jsw. Include the following code in this file:
Add the following page elements to your site:
Import the getValuesWrapper()
function from the web module to your page code and run it when the button is clicked.
The following describes how you can use this package to add data to the next empty row of your spreadsheet.
Note: The appendValues()
function appends data to your spreadsheet linearly. If there are blank cells in between data cells, the function may not work as expected.
To use the appendValues()
function in your page code, add a web module to your backend. We’ll call ours googlesheet-wrapper.jsw. Include the following code in this file:
Add the following page elements to your site:
Import the appendValuesWrapper()
function from the web module to your page code and run it when the button is clicked.
The following describes how you can use this package to update the data in the first row of your spreadsheet (A1:B1
). If you want to update data from a different location in your spreadsheet, simply pass a different range
and dimension
to the updateValuesWrapper()
function located in the updateValuesOnSheet()
function in your page code.
To use the updateValues()
function in your page code, add a web module to your backend. We’ll call ours googlesheet-wrapper.jsw. Include the following code in this file:
Add the following page elements to your site:
Import the updateValuesWrapper()
function from the web module to your page code and run it when the button is clicked.
The following describes how you can use this package to clear a range of data from your spreadsheet:
To use the clearValues()
function in your page code, add a web module to your backend. We’ll call ours googlesheet-wrapper.jsw. Include the following code in this file:
Add the following page elements to your site:
Import the clearValuesWrapper()
function from the web module to your page code and run it when the button is clicked.
This Velo package uses the following npm package. To view the npm license, see the npm readme.
1.0 Initial version.
google, spreadsheet, googleapis