在Google表格中设置行高 [英] Setting row heights in google sheets

查看:763
本文介绍了在Google表格中设置行高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在App脚本中使用setRowHeights来更改google工作表中的行高.它会改变高度,但是当您返回工作表并选择调整大小"行时,单选按钮仍将设置为适合数据".而不是指定行高",我如何将其切换为单选按钮,我希望将其设置为指定行高"

I am using setRowHeights in App Script to change the row heights in a google sheet. It changes the height but when you go back to the sheet and pick resize row the radio button is still set to "fit to data" not "specify row height", how do I get it to toggle the radio button, I would like it set to "specify row height"

function macro() {
  var ss = SpreadsheetApp.getActive();
  ss.getSheets()[0].setRowHeights(4,ss.getLastRow(), 24);
}

推荐答案

要使用Apps Script调整行的大小以适合数据,您可以使用方法

To resize the rows to fit the data with Apps Script you can use the method autoResizeRows(startRow, numRows)

这将自动检测每一行所需的高度,并将分别调整每一行的大小:

This will automatically detect the needed height for each row and will resize each one individually:

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Sets the first 15 rows to a height that fits their text.
sheet.autoResizeRows(1, 15);

这篇关于在Google表格中设置行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆