Follow

Show this Google Sheets API feature request some love with a comment or +1!:

## Inclusion of a 'setToFit' boolean in row metadata. `pixelSize` does not accurately read row assigned 'Fit to data'

### Description

#### Issue
There is currently no way to get or set the row height to `Fit to data` in the same way that you can in Google Sheets by right-clicking the row, `Resize row` > `Fit to data`.

The closest approximation is in `rowMetadata` > `pixelSize`. However, pixel size is inaccurately read when the row is set to `Fit to data`, reading only the default 21 pixels even when the data may expand the height of the row beyond this pixel height.

See this bug report for an example: [There is no way to get the real height of a row if its height is based on the height of the content in its cells.](issuetracker.google.com/issues). _*The Googler assigned to this bug recommended that a feature request should be made. This is the feature request._

#### Proposed Solution
Introduce the property: `setToFit` as a boolean into `rowMetadata` array of objects alongside `pixelSize`.

Just like when assigning `Fit to data` in Google Sheets, `setToFit` would take priority over `pixelSize` setting any row that has `setToFit` marked as `true` to a row height that would fit the data.

This is a low-memory solution for the API (boolean property) and does not require any modification of existing properties allowing it to be added to the existing API v4.

### Impact
Currently, devs must manually ensure that each row of data is not set to `Fit to data` before modifying duplicating or cutting and pasting ranges with the correct row height. Otherwise, the row heights will not be accurately represented.

With the inclusion of `setToFit` developers would be able to accurately determine if selected rows are based on the actual pixel height or `Fit to data`.

#### Getting and setting the row heights
Let's say a developer wants to copy a range of data from one Google Sheet or Sheet tab to another and ensure that they also duplicate the correct row height.

When iterating over their `rowMetadata` they would first check if `setToFit` is `true` If so, they would mark the property to true in their batch upload payload, otherwise, they would set the `pixelSize`.

issuetracker.google.com/issues

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.