Search code examples
pythongoogle-sheetsgoogle-sheets-apigspreadgspread-formatting

Hide gridlines with the Google Sheets API in Python


I want to remove all the gridlines in my google sheet. I think I need to use batchupdate in combination with a JSON request that sets the hideGridlines in gridProperties to True but I can't seem to get it to work.

Anyone knows how to do this?

This is what I have so far but it gives an error about not having a sheet name.

     [{
         'updateSheetProperties': {
                "fields": "*",
                "properties": {
                    "gridProperties": {
                        "hideGridlines": True,
                    },
                    "sheetId": self.sheet.id,
                },
            },
        }]

Solution

  • I thought that in your showing request body, it is required to modify the value of fields as follows.

    From:

    "fields": "*",
    

    To:

    "fields": "gridProperties.hideGridlines",
    

    Reference: