0

In Google Sheets, if you click InsertPre-built tables and then for example Blank table, the vertical padding of cells changes and userEnteredFormat.padding stops having an effect (you can try userEnteredFormat.padding by clicking API on the right here or copying the following code).

{ "requests": [ { "updateCells": { "rows": [ { "values": [ { "userEnteredFormat": { "padding": { "bottom": 0, "left": 0, "right": 0, "top": 0 } } } ] } ], "start": { "columnIndex": 0, "rowIndex": 1, "sheetId": 0 }, "fields": "userEnteredFormat.padding" } } ] } 

repeatCell has the same problem, see the comment below for a link to that code.

Maybe the so-called table object (or each of its rows or columns) has its own vertical padding value that overrides the value of individual cells. How can I change the vertical padding for all cells of the table?

Table menu (alternatively: Format) → Table formattingShow condensed view allows switching between only two padding values. I'm looking for other values.

Note: Resize row is set to Fit to data by default. Please don't change that. My question is about that kind of rows.

10
  • 1
    If you want to achieve How can I change the vertical padding for all cells of the table? using userEnteredFormat.padding, how about using repeatCell? And, in your actual situation, what values do you want to set for bottom and top as the padding of all cells in the table? But, if I misunderstood your expected result, I apologize. Commented Aug 12 at 2:42
  • 3
    Thank you for replying. From Padding 0 would be nice., I understood that you wanted to set the padding to 0. I think that in the current stage, this cannot be achieved. Can I ask you about the problem between Show condensed view and your goal? Commented Aug 12 at 6:31
  • 2
    @doubleunary As far as I know, this code isn't an official example. It appears in the APIs Explorer because it is encoded in the URL. Unlike JSFiddle, such URLs contain the whole code. So my question always had a minimal example. That code is what I tried. The question also mentions what I tried in the UI. Commented Aug 12 at 14:27
  • 1
    @Wicket Thank you for your comment. In this case, I think that the fields can be used to manage the specific fields. For example, when userEnteredFormat.padding is used for the fields, only userEnteredFormat.padding is modified. But if I misunderstood your comment, I have to apologize. I think that such a discussion is very valuable. Commented Aug 12 at 23:21
  • 1
    @Wicket Thank you for replying. I think that your answer is correct. The OP wants to set the padding of cells in the table to 0. But, in the current stage, this cannot be achieved in the bachUpdate methods for managing the table. The padding can be managed by userEnteredFormat.padding. This can also be used with UpdateCellsRequest by providing the range. From this situation, I think that your answer is useful for this question. Commented Aug 13 at 1:32

2 Answers 2

4

Not all the features available in the Sheets web application are available in Apps Script and the Sheets API.

To set the padding to the smallest size possible for a Google Sheets Table, you must do this from the Sheets web app UI by clicking the Table menu, then Table Formatting > Show condensed view.


As of August 12th, 2025, Google Sheets Table's cell padding cannot be set with Google Apps Script or the Google Sheets API. If you want to modify a table, instead of messing around with the UpdateCellsRequest, you have to look at UpdateTableRequest because the table format overrides the individual cell format.

Unfortunately, UpdateTableRequest doesn't include a padding property.

If you want to programmatically set the vertical padding for a specific cell or range, you should forget about using Google Sheets Tables on the range containing that cell or range.

Sign up to request clarification or add additional context in comments.

3 Comments

I want to set vertical padding for all cells of the table.
Following links from UpdateCellsRequest doesn't lead to anything that sounds like clicking FormatTable formattingShow condensed view. Does this mean that the API can't do some things that the UI can, or that parts of the API are undocumented?
@root You are right. The Sheets API, like the Google Apps Script Spreadsheet service, doesn't support everything that can be done using the Google Sheets web UI.
1

In my previous answer, I didn't consider batchUpdate > repeatCell. Tanaike mentioned it in a comment to the question after I posted the first revision. After playing a bit with repeatCell in the Google APIs playground and the Google Sheets web app, I learned that we can set the padding of the range in a Google Sheets Table.

I inserted a prebuilt blank table, then applied a padding of 0,0,0,0 to A2:F15.

Screenshot

Notes:

  • The cell vertical alignment was set to top, and the cell horizontal alignment is the default, which is left for text values.
  • The white space to the right and below the "Hello world!" text is due to the row height and column width.

Below is the working request used in the Google APIs playground.

{ "requests": [ { "repeatCell": { "fields": "userEnteredFormat.padding", "cell": { "userEnteredFormat": { "padding": { "top": 0, "right": 0, "bottom": 0, "left": 0 } } }, "range": { "sheetId": 0, "startRowIndex": 1, "startColumnIndex": 0, "endRowIndex": 14, "endColumnIndex": 5 } } } ] } 

Warning: Using "fields": "*" will clear the range content and might have other side effects.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.