I am currently trying to write some Google Apps Script script that would allow my Google sheet table to fit to data, but with some row height cap.
The easiest way that came into my mind was first fit everything to data, and then walk over every row to check whether its height is more than some value and then fix it if it is too high.
sheet.autoResizeRows(startRow, numRows)
for (var i=0;i<numRows;i++){
var curHeight = sheet.getRowHeight(startRow + i)
Logger.log(curHeight)
if (curHeight > 50){
sheet.setRowHeight(startRow + i, 50)
}
}
However, what I found out is that .getRowHeight()
always returns 20.0 - the default value.
Thus, do I miss something or .getRowHeight()
does not work properly with fit to data rows, and if not is there a workaround?