Search code examples
javaapigoogle-sheetsfreezegoogle-sheets-api

Freeze rows and set styles with Google spreadsheet API


If i scroll the spreadsheet ,header field of the rows are hidden and I need bold text format in the same spreadsheet.

Question
Can I set the freeze rows and styles through the spreadsheet api - Is it possible?


Solution

  • This is now available in the v4 API.

    Here is the reference for the JAVA API implementation: https://developers.google.com/resources/api-libraries/documentation/sheets/v4/java/latest/com/google/api/services/sheets/v4/model/GridProperties.html#setFrozenRowCount(java.lang.Integer)

    Here is the API documentation: https://developers.google.com/sheets/reference/rest/v4/spreadsheets#gridproperties

    If you want to do it w/ an App Script you can as well: https://developers.google.com/apps-script/reference/spreadsheet/sheet#setFrozenRows(Integer)

    This is the request I made w/ the Ruby API:

    update_sheet_properties: {
      properties: {
        sheet_id: 'YOUR SHEET ID HERE',
        grid_properties: { frozen_row_count: 4 }
      },
      fields: 'gridProperties.frozenRowCount'
    }