(Feb 2017) As of Google I/O 2016, developers no longer need to export to Excel nor create a new Sheet w/the desired formatting, so the other answers are now dated. You can now format cells using the Google Sheets API. Here's a short Python example that bolds the 1st row (assuming the file ID is SHEET_ID and SHEETS is the API service endpoint):

DATA = {'requests': [
    {'repeatCell': {
        'range': {'endRowIndex': 1},
        'cell':  {'userEnteredFormat': {'textFormat': {'bold': True}}},
        'fields': 'userEnteredFormat.textFormat.bold',
    }}
]}

SHEETS.spreadsheets().batchUpdate(
        spreadsheetId=SHEET_ID, body=DATA).execute()

I also made a developer video on this subject if that helps (see below). BTW, you can do the same in Ruby (see its API quickstart sample) or any other language supported by the Google APIs Client Libraries.

The Sheets API provides features not available in older releases, namely giving developers programmatic access to a Sheet as if you were using the user interface (frozen rows, cell formatting[!], resizing rows/columns, adding pivot tables, creating charts, etc.). If you're new to the API, I've created a few videos with somewhat more "real-world" examples:

  • Migrating SQL data to a Sheet plus code deep dive post
  • Formatting (text in) cells using the Sheets API plus code deep dive post
  • Generating slides from spreadsheet data plus code deep dive post

To see what else you can do with Google Sheets via its REST API or Google Apps Script, check out my other videos. As you can tell, the Sheets API is primarily for document-oriented functionality as described above, but to perform file-level access such as import/export, copy, move, rename, etc., use the Google Drive API instead.

Answer from wescpy on Stack Overflow
🌐
Google
developers.google.com › google workspace › google sheets › basic formatting
Basic formatting | Google Sheets | Google for Developers
April 20, 2026 - The first request updates the text color, the background color, the text font size, and the text justification and makes the text bold. Omitting the column indices in the range field causes the entire row to be formatted. The second request adjusts the sheet properties so that the header row is frozen.
Home
Use Apps Script to create a custom Sheets formula, automate actions based on Form responses, and more. ... Create custom Google Chat apps to get information, send reminders, or automate tasks. ... Create Google Workspace add-ons to display relevant information alongside a user's email, files, or calendar. ... Use the Google Workspace Marketplace to reach millions of users and organizations with your solutions. ... REST APIs ...
Apps Script
Develop high-quality, cloud-based solutions with ease.
How to get started
Google Workspace offers developer products and tools to connect or extend Google Workspace apps like Gmail, Drive, and Chat, each with its own Google Cloud project for API configuration, authentication, and deployments.
Guides
Sheet1!R[3]C[1] refers to the cell that is three rows below and one column to the right of the current cell. ... A defined cell or range of cells with a custom name to simplify references throughout an application. A FilterView resource represents a named range. ... A defined cell or range of cells that cannot be modified. A ProtectedRange resource represents a protected range. To learn about developing with Google Workspace APIs...
Top answer
1 of 5
8

(Feb 2017) As of Google I/O 2016, developers no longer need to export to Excel nor create a new Sheet w/the desired formatting, so the other answers are now dated. You can now format cells using the Google Sheets API. Here's a short Python example that bolds the 1st row (assuming the file ID is SHEET_ID and SHEETS is the API service endpoint):

DATA = {'requests': [
    {'repeatCell': {
        'range': {'endRowIndex': 1},
        'cell':  {'userEnteredFormat': {'textFormat': {'bold': True}}},
        'fields': 'userEnteredFormat.textFormat.bold',
    }}
]}

SHEETS.spreadsheets().batchUpdate(
        spreadsheetId=SHEET_ID, body=DATA).execute()

I also made a developer video on this subject if that helps (see below). BTW, you can do the same in Ruby (see its API quickstart sample) or any other language supported by the Google APIs Client Libraries.

The Sheets API provides features not available in older releases, namely giving developers programmatic access to a Sheet as if you were using the user interface (frozen rows, cell formatting[!], resizing rows/columns, adding pivot tables, creating charts, etc.). If you're new to the API, I've created a few videos with somewhat more "real-world" examples:

  • Migrating SQL data to a Sheet plus code deep dive post
  • Formatting (text in) cells using the Sheets API plus code deep dive post
  • Generating slides from spreadsheet data plus code deep dive post

To see what else you can do with Google Sheets via its REST API or Google Apps Script, check out my other videos. As you can tell, the Sheets API is primarily for document-oriented functionality as described above, but to perform file-level access such as import/export, copy, move, rename, etc., use the Google Drive API instead.

2 of 5
4

Smartsheet utilizes the ability of the Google API to import an Excel file. The code is roughly along these lines:

DocsService client = new DocsService(<YOUR APP NAME>);
client.setOAuthCredentials(<OAUTH PARAMETERS>);

DocumentListEntry newEntry = new SpreadsheetEntry();
newEntry.setMediaSource(new MediaByteArraySource(<EXCEL FILE BYTE ARRAY OUTPUT STREAM>, DocumentListEntry.MediaType.XLS.getMimeType()));
newEntry.setTitle(new PlainTextConstruct(<FILE NAME>));

DocumentListEntry insertedEntry = client.insert(new URL("https://docs.google.com/feeds/default/private/full/"), newEntry);

// This is your URL to the new doc
String docUrl = insertedEntry.getDocumentLink().getHref();

We already had the ability to export a Smartsheet to an Excel file with formatting via Apache POI. Adding export to a Google Spreadsheet was quite simple for us to implement and it provided some additional functionality beyond what you could do via the API.

Sorry for the delayed response - just happened across this question.

Discussions

Formatting cells with the Google Sheets API (v4)
I'm using the Google Sheets API (v4) to create/update spreadsheets programmatically and have run into the following issue: As per the documentation (https://developers.google.com/sheets/api/reference/ More on stackoverflow.com
🌐 stackoverflow.com
How to retrieve sheet data with formatting with Google Sheets Api V4 - Stack Overflow
I want to retrieve only sheet's data from a spreadsheet with formatting. How to achieve the same with Sheets Api? More on stackoverflow.com
🌐 stackoverflow.com
December 27, 2016
How to set formatting with Google sheets API for python? - Stack Overflow
In theory this was answered in Remove only formatting on a cell range selection with google spreadsheet API but for the life of me I cannot get it to work. I want to write a function that clears the More on stackoverflow.com
🌐 stackoverflow.com
formatting - Set cell format in Google Sheets spreadsheet using its API & Python - Stack Overflow
BTW, you're not limited to Python, ... by the Google APIs Client Libraries. The latest Sheets API provides features not available in older releases, namely giving developers programmatic access to a Sheet as if you were using the user interface (frozen rows, cell formatting[!], resizing ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Google Cloud
cloud.google.com › blog › products › application-development › formatting-cells-with-the-google-sheets-api
Formatting cells with the Google Sheets API | Google Workspace Blog
October 11, 2022 - The Sheet created using the code from that video is where we pick up today. Formatting spreadsheets is accomplished by creating a set of request commands in the form of JSON payloads, and sending them to the API.
🌐
DEV Community
dev.to › jessesbyers › add-basic-and-conditional-formatting-to-a-spreadsheet-using-the-google-sheets-api-376f
Add Basic and Conditional Formatting to a Spreadsheet Using the Google Sheets API - DEV Community
January 5, 2021 - If you've just landed here, make ... with the click of a button. In this article, I'll describe how I used vanilla JavaScript and the Google Sheets API to add basic formatting as well as conditional formatting to the cells of the spreadsheet....
🌐
DataCamp
datacamp.com › tutorial › google-sheets-api
Google Sheets API: A Step-by-Step Guide For Beginners | DataCamp
January 6, 2026 - Using the API, conditional formatting rules are defined in JSON and applied via spreadsheets.batchUpdate. ... For example, you can define a rule that highlights any value below 0 in a specific column. Once applied, the formatting updates automatically as the data changes.
🌐
Google Developers
developers.googleblog.com › google for developers blog › formatting cells with the google sheets api
Formatting cells with the Google Sheets API - Google Developers Blog
November 16, 2016 - {"requests": [ {"repeatCell": { "range": { "sheetId": 0, "startRowIndex": 0, "endRowIndex": 1 }, "cell": { "userEnteredFormat": { "textFormat": { "bold": true } } }, "fields": "userEnteredFormat.textFormat.bold" }} ]} With at least one request, say in a variable named requests and the ID of the sheet as SHEET_ID, you send them to the API via an HTTP POST to · https://sheets.googleapis.com/v4/spreadsheets/{SHEET_ID}:batchUpdate, which in Python, would be a single call that looks like this:
Find elsewhere
🌐
Google
developers.google.com › google workspace › google sheets › date and number formats
Date and number formats | Google Sheets | Google for Developers
In the Sheets UI, you apply number and date formats to cells using the Format > Number menu. In the Google Sheets API, you set these formats using a spreadsheets.batchUpdate method call to send an UpdateCellsRequest or RepeatCellRequest.
🌐
Google
developers.google.com › google workspace › google sheets › conditional formatting
Conditional formatting | Google Sheets | Google for Developers
April 20, 2026 - The Google Sheets API lets you create and update the conditional formatting rules in spreadsheets. Only certain formatting types (bold, italic, strikethrough, foreground color, and background color) can be controlled through conditional formatting.
🌐
Google
developers.google.com › google workspace › google sheets › google sheets api overview
Google Sheets API Overview | Google for Developers
April 20, 2026 - The Google Sheets API is a RESTful interface that lets you read and modify a spreadsheet's data. The Sheets API lets you: Create spreadsheets · Read and write spreadsheet cell values · Update spreadsheet formatting · Manage Connected Sheets · The following is a list of common terms used in the Sheets API: Spreadsheet ·
🌐
Sheets Bootcamp
sheetsbootcamp.com › home › google sheets api: read and write data programmatically
Google Sheets API: Read and Write Data Programmatically | Sheets Bootcamp
February 27, 2026 - Use Apps Script for quick automations inside a sheet, and the API for external integrations. Yes. The spreadsheets.batchUpdate method lets you apply formatting like bold text, background colors, number formats, and conditional formatting rules.
🌐
GitHub
gist.github.com › tanaikech › 76cde17cecba38f44398c3effe2aedf2
Setting Number Format of Cells on Google Spreadsheet using batchUpdate in Sheets API with golang · GitHub
repeatCellRequest := &sheets.RepeatCellRequest{ Fields: "userEnteredFormat.numberFormat", Range: &sheets.GridRange{ SheetId: int64(sheetId), StartRowIndex: 0, StartColumnIndex: 0, EndColumnIndex: 1, }, Cell: &sheets.CellData{ UserEnteredFormat: &sheets.CellFormat{ NumberFormat: &sheets.NumberFormat{ Pattern: "yyyy-mm-dd hh:mm:ss", Type: "DATE", }, }, }, } requestBody := &sheets.BatchUpdateSpreadsheetRequest{ Requests: []*sheets.Request{&sheets.Request{ RepeatCell: repeatCellRequest, }}, } resp, err := srv.Spreadsheets.BatchUpdate(bookID, requestBody).Do() if err != nil { log.Fatal(err) } fmt.Printf("%#v\n", resp)
🌐
MoldStud
moldstud.com › articles › developers faq › google sheets api developers questions › mastering cell formatting with google sheets api - a developer's toolkit
Mastering Cell Formatting with Google Sheets API - A Developer's Toolkit
June 23, 2025 - Yes, you can definitely use the API to merge cells, adjust row heights, and column widths. It's all about customizing the layout of your data. ... Sometimes I struggle with getting the formatting just right. Do you guys have any tips or tricks for mastering cell formatting in Google Sheets?
🌐
Latenode
latenode.com › home › blog › google sheets api: what it is and how to use it
Google Sheets API: What It Is and How to Use It - Latenode Blog
2 weeks ago - The API offers a wide range of formatting options, from text styles to cell colors and borders. When using the Google Sheets API, it's important to structure your code efficiently, handle errors gracefully, and be mindful of API quotas.
🌐
npm
npmjs.com › package › google-spreadsheet
google-spreadsheet - npm
await sheet.loadCells('A1:E10'); // loads range of cells into local cache - DOES NOT RETURN THE CELLS console.log(sheet.cellStats); // total cells, loaded, how many non-empty const a1 = sheet.getCell(0, 0); // access cells using a zero-based index const c6 = sheet.getCellByA1('C6'); // or A1 style notation // access everything about the cell console.log(a1.value); console.log(a1.formula); console.log(a1.formattedValue); // update the cell contents and formatting a1.value = 123.456; c6.formula = '=A1'; a1.textFormat = { bold: true }; c6.note = 'This is a note!'; await sheet.saveUpdatedCells();
      » npm install google-spreadsheet
    
Published   Jun 03, 2026
Version   5.3.0
🌐
Google
developers.google.com › google workspace › google sheets › basic writing
Basic writing | Google Sheets | Google for Developers
The examples on this page illustrate ... spreadsheets.values resource of the Sheets API. Note that it's also possible to write cell values using the spreadsheet.batchUpdate method, which can be useful if you want to simultaneously update cell formatting or other properties the ...