Sheet operations  |  Google Sheets  |  Google for Developers (2024)

The Google Sheets API lets you create, clear, copy, and delete sheets, and alsocontrol their properties. The examples on this page illustrate how you canachieve some common Sheets operations with theSheets API.

These examples are presented in the form of HTTP requests to be languageneutral. To learn how to implement a batch update in different languages usingthe Google API client libraries, see Updatespreadsheets.

In these examples, the placeholders SPREADSHEET_ID and SHEET_IDindicates where you would provide those IDs. You can find the spreadsheetID in the spreadsheet URL. You can getthe sheet ID by using thespreadsheets.get method. Theranges are specified using A1 notation. Anexample range is Sheet1!A1:D5.

Add a sheet

The followingspreadsheets.batchUpdatecode sample shows how to use theAddSheetRequestto add a sheet to a spreadsheet, while also setting the title, grid size, andtab color.

The response consists of aAddSheetResponse,which contains an object with the created sheet's properties (such as itsSHEET_ID).

The request protocol is shown below.

POST https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID:batchUpdate
{ "requests": [ { "addSheet": { "properties": { "title": "Deposits", "gridProperties": { "rowCount": 20, "columnCount": 12 }, "tabColor": { "red": 1.0, "green": 0.3, "blue": 0.4 } } } } ]}

Clear a sheet of all values while preserving formats

The followingspreadsheets.batchUpdatecode sample shows how to use theUpdateCellsRequestto remove all values from a sheet while leaving the formatting unaltered.

Specifying theuserEnteredValue fieldwithout a corresponding value is interpreted as an instruction to clear valuesin the range. This setting can be used with other fields as well. For example,changing the fields value touserEnteredFormat removesall formatting supported by the Sheets APIfrom the sheet, but leaves the cell values unaltered.

The request protocol is shown below.

POST https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID:batchUpdate
{ "requests": [ { "updateCells": { "range": { "sheetId": SHEET_ID }, "fields": "userEnteredValue" } } ]}

Copy a sheet from one spreadsheet to another

The followingspreadsheet.sheets.copyTocode sample shows how to copy a single sheet specified by SHEET_IDfrom one spreadsheet to another spreadsheet.

The TARGET_SPREADSHEET_ID variable in the request body specifies thedestination spreadsheet. The copy retains all values, formatting, formulas, andother properties of the original. The title of the copied sheet is set to "Copyof [original sheet title]".

The response consists of aSheetPropertiesobject describing the properties of the created sheet.

POST https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/sheets/SHEET_ID:copyTo
{ "destinationSpreadsheetId": "TARGET_SPREADSHEET_ID"}

Delete a sheet

The followingspreadsheets.batchUpdatecode sample shows how to use theDeleteSheetRequestto delete a sheet specified by SHEET_ID.

The request protocol is shown below.

POST https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID:batchUpdate
{ "requests": [ { "deleteSheet": { "sheetId": SHEET_ID } } ]}

Read sheet data

The followingspreadsheets.get code sampleshows how to get sheet property informationfrom a spreadsheet, specified by SHEET_IDand SPREADSHEET_ID. This method is often used to determine themetadata of sheets within a specific spreadsheet, so additional operations cantarget those sheets. The fields query parameter specifies only sheet propertydata should be returned (as opposed to cell value data or data related to theentire spreadsheet).

GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID?&fields=sheets.properties

The response consists of aSpreadsheetresource, which contains aSheet object withSheetPropertieselements. If a given response field is set to the default value, it's omittedfrom the response.

{ "sheets": [ { "properties": { "sheetId": SHEET_ID, "title": "Sheet1", "index": 0, "sheetType": "GRID", "gridProperties": { "rowCount": 100, "columnCount": 20, "frozenRowCount": 1 } "tabColor": { "blue": 1.0 } }, ... ],}
Sheet operations  |  Google Sheets  |  Google for Developers (2024)
Top Articles
Breast Reduction Recovery
How to Lose Belly Fat in a Week: Diet & Exercise Tips
Katie Nickolaou Leaving
Victor Spizzirri Linkedin
Obor Guide Osrs
Falgout Funeral Home Obituaries Houma
Toyota gebraucht kaufen in tacoma_ - AutoScout24
Is Csl Plasma Open On 4Th Of July
Rochester Ny Missed Connections
Jscc Jweb
Craigslist Chautauqua Ny
Marion County Wv Tax Maps
Dump Trucks in Netherlands for sale - used and new - TrucksNL
Premier Reward Token Rs3
Moonshiner Tyler Wood Net Worth
Eka Vore Portal
Craigslist Malone New York
Northern Whooping Crane Festival highlights conservation and collaboration in Fort Smith, N.W.T. | CBC News
Les Rainwater Auto Sales
1v1.LOL - Play Free Online | Spatial
Raz-Plus Literacy Essentials for PreK-6
Free Personals Like Craigslist Nh
Foolproof Module 6 Test Answers
Boise Craigslist Cars And Trucks - By Owner
Delectable Birthday Dyes
Sensual Massage Grand Rapids
Gillette Craigslist
Jackass Golf Cart Gif
Pokémon Unbound Starters
Craigslist Boerne Tx
134 Paige St. Owego Ny
Missing 2023 Showtimes Near Mjr Southgate
Dubois County Barter Page
Southern Democrat vs. MAGA Republican: Why NC governor race is a defining contest for 2024
ShadowCat - Forestry Mulching, Land Clearing, Bush Hog, Brush, Bobcat - farm & garden services - craigslist
Roto-Rooter Plumbing and Drain Service hiring General Manager in Cincinnati Metropolitan Area | LinkedIn
House Of Budz Michigan
Craigslist Georgia Homes For Sale By Owner
Hindilinks4U Bollywood Action Movies
Bones And All Showtimes Near Johnstown Movieplex
'Guys, you're just gonna have to deal with it': Ja Rule on women dominating modern rap, the lyrics he's 'ashamed' of, Ashanti, and his long-awaited comeback
Trivago Anaheim California
Exploring the Digital Marketplace: A Guide to Craigslist Miami
فیلم گارد ساحلی زیرنویس فارسی بدون سانسور تاینی موویز
[Teen Titans] Starfire In Heat - Chapter 1 - Umbrelloid - Teen Titans
Darkglass Electronics The Exponent 500 Test
Strange World Showtimes Near Marcus La Crosse Cinema
Join MileSplit to get access to the latest news, films, and events!
Jeep Forum Cj
Doelpuntenteller Robert Mühren eindigt op 38: "Afsluiten in stijl toch?"
Runescape Death Guard
Naughty Natt Farting
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 5647

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.