Use Google Workspace to create Google Sheets
- How to use Google Workspace to import data from an excel sheet and create a new Google spreadsheet
- How to retrieve the details of a Google spreadsheet
- How to set the values of a specified cells range in Google Sheet
Prerequisites
- Complete Google Authorization tutorial
- Install and set up the Desktop Agent 3 to run the automation
In this tutorial, you will build an automation that will import data from an excel file, create a Google spreadsheet named Order Details with the values from the excel file. The automation will then create a new Google sheet within the spreadsheet named Updated Order Status with values set to a specified cell range.
- Step 1
In the Lobby, select the Google Suite project that has been done as part of previous tutorials as mentioned in pre-requisites.
In Build Process Automation, choose Create and then select Automation.
In the Create Automation window, enter Google Workspace-Sheets as name and An automation to use Google Sheets as a description.
You will be navigate to the automation editor of the newly created automation.
- Step 2
You will add one input parameter.
In the Automation Details panel, under Input/Output, choose Add new input parameter.
Add an input parameter as follows:
Field Input Parameter 1 Name excelPath
Type String - Step 3
-
In the Automation Details panel, under Automations, drag and drop the Google Authorization automation you created.
You will import data and create a new Google spreadsheet.
-
In the Automation Details panel, under Tools, search for the Import and Create (Google Sheet) and drag and drop it into the workflow.
-
Select the activity. For the location parameter select
fileSystem
and for thepathOrDriveFileId
select0 excelPath
.The location parameter refers to the type of location from which to pick the data to import and the path or drive field parameter refers to the path to the excel file stored on your local machine.
-
Now search for the Rename Spreadsheet (Google Sheet) and drag and drop it into the workflow.
This activity will rename the existing Google spreadsheet.
-
Select the activity. For the
spreadsheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.spreadSheetId
. -
In the
newTitle
parameter field, enterOrderDetails
.This will rename the Google spreadsheet that you previously created to
OrderDetails
. -
Search for Get Spreadsheet Details (Google Sheet) activity. Drag and drop it into the workflow.
-
Select the activity. For the
spreadSheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.spreadSheetId
.Now that you retrieved the details of the Google spreadsheet, you can get the details of a specific row.
-
Search for the Get Last Row (Google Sheet) activity to retrieve the details of last row. Drag and drop it into the workflow.
-
Select the activity. For the
spreadSheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.spreadSheetId
. -
For the
sheetTitle
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.sheets[0].title
.This specifies the name of the sheet in which you want to get the last row.
-
Search for the Get Cell Values (Google Sheet) activity. Drag and drop it into the workflow.
This activity returns the values of the specified cell range in Google.
-
Select the activity. For the
spreadSheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.spreadSheetId
. -
Under the range parameter field, select Custom Data.
-
For the
sheetTitle
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.sheets[0].title
. -
For the
startRange
parameter, enter A1. -
For the
endRange
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
"A" + Step5.lastRow
. -
Finally, for the
majorDimension
parameter, select rows. -
You will now add a sheet. To do so, search for the Add Sheet (Google Sheet) activity. Drag and drop it into the workflow.
-
Select the activity. For the
spreadSheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.spreadSheetId
. -
You will rename this new sheet to Updated Order Status. To do so, search for the Rename Sheet (Google Sheet). Drag and drop it into the workflow.
-
Select the activity. For the
spreadSheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.spreadSheetId
. -
For the
sheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step7.sheetDetails.sheetId
. -
For the
newTitle
parameter, enterUpdatedOrderStatus
and select the text in quotes. -
Search for the Set Cell Values (Google Sheet) activity. Drag and drop it into the workflow.
With Set Cell Values (Google Sheet) activity you push the values of a specified cell range in to Google sheet.
-
Select the activity. For the
spreadSheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.spreadSheetId
. -
For the range parameter, select Custom Data.
-
For
sheetTitle
parameter, enterUpdatedOrderStatus
and select the text in quotes. -
For the
startRange
parameter, enter A1 and select the text in quotes. -
For the
endRange
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
"A" + Step5.lastRow
. -
For the values parameter, select the pencil next to the field to open the expression editor.
-
In the expression editor, copy and paste the following expression:
Step6.cellsData.values
. -
For
majorDimension
parameter, select rows and forvalueInputOption
parameter, selectuserEntered
. -
Drag and drop another Set Cell Values (Google Sheet) activity.
-
Select the activity. For the
spreadSheetId
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
Step2.spreadSheetDetails.spreadSheetId
. -
For the range parameter, select Custom Data.
-
For
sheetTitle
parameter, enterUpdatedOrderStatus
and select the text in quotes. -
For the
startRange
parameter, enter B1 and select the text in quotes. -
For the
endRange
parameter, select the pencil next to the field to open the expression editor. -
In the expression editor, copy and paste the following expression:
"B" + Step5.lastRow
. -
For the values parameter, select the pencil next to the field to open the expression editor.
-
In the expression editor, copy and paste the following expression:
['Order Status', 'Delivered', 'Delivered', 'In Time', 'In Time', 'Delivered', 'In Time', 'Delivered', 'In Time', 'In Time', 'Delivered']
. -
For the
majorDimension
parameter, select rows.Finally, you need to disconnect the Google Account.
-
Search for the Disconnect (Google) activity and drag and drop it into the workflow.
-
Save your work.
Which activity do you use to fetch values of a specified cell range in Google Sheet?
-
- Step 4
Choose Test.
Fill in the Input parameters:
- For
excelPath
: the full path to the excel file
- For
Fill in the Environment Variables:
- For
userEmail
: your Gmail user email - For
serviceAccountKeyPath
: the full path to the json file
- For
Choose Test.
The testing was successful.
If you go to your Google Account>Google Apps>Sheets you will see the created
OrderDetails
spreadsheet. Upon opening it, you will see the values from the excel file were imported on sheet1 and a new sheet was created namedupdatedOrderStatus
with the corresponding values that were set in your automation.