Google表格setRowHeight()自动调整,不会调整为设置值的大小 [英] Google Sheets setRowHeight() auto-fitting, NOT resizing to set value

查看:86
本文介绍了Google表格setRowHeight()自动调整,不会调整为设置值的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google表单/工作表,用于收集数据,创建数据的单元格是如此之大,以至于上下导航变得很棘手.

I've a Google form/sheet which collects data creating cells that are so large that navigating up and down rows becomes tricky.

下面的函数应将所有行(标题行1除外)的大小调整为50.但是,当它运行时,所有行都会自动拟合数据,再次使其变得难以处理.

The below function should resize all rows (except the header row 1) to 50. However, when it runs, all rows Auto-fit the data, again making it again unwieldy.

var sheetResponses = 'Form responses 3';
var ss = SpreadsheetApp.getActiveSpreadsheet();
var responsesSheet = ss.getSheetByName(sheetResponses);
var responseData = responsesSheet.getDataRange().getValues();

// Sets all rows to a height of 50
function resizeRowsTo50() {
  responsesSheet.setRowHeights(2,responseData.length,50);
};

有人可以发现我做错了什么吗?即使我事先手动将所有行的大小调整为统一的高度,该函数也会将它们还原为适合数据的大小.

Can anyone spot what I've done wrong? Even if I manually resize all of the rows to a uniform height beforehand, the function reverts them back to fit the data.

谢谢.

链接到工作表

推荐答案

setWrap setWraps 似乎覆盖了任何手册或编程的( setRowHeight / setRowHeights )行高调整.

It appears that setWrap and setWraps override any manual or programmed (setRowHeight/setRowHeights) row height adjustment.

setWrap setWraps 的文档说:"启用了包装的单元格(默认)会调整大小以显示其全部内容"(强调是我的).即,单元格宽度保持不变,并且行高改变以使得能够显示整个内容.

The documentation for setWrap and setWraps says "Cells with wrap enabled (the default) resize to display their full content" (emphasis is mine). That is, the cell width remains unchanged, and the row height changes to enable display of the entire content.

它继续...禁用了换行的单元格在单元格中尽可能多地显示,而无需调整大小或运行到多行".在后一种情况下,显示的文本量取决于列的宽度.

It goes on... "Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines". In the later case, the amount of text displayed otherwise depends on the width of the column.

相比之下,手动调整设置(行高设置为50像素,文本换行设置为自动换行)时,该行恢复为自动调整.

By comparison, when the settings are adjusted manually (the row height set to 50 pixels and text wrapping set to wrap), the row does not revert to auto-fit.

我已经重新运行了最初的测试,并且我相信比较结果时可能会误解您的自动拟合注释.我很抱歉.

I've re-run my initial tests and I believe that I may misinterpreted your auto-fit comments when comparing my results. My apologies.

自动调整结果在Google看来是故意的-即使其效果与手动换行"调整的效果非常不同.这些是相对较新的命令(在撰写本文时),网上几乎找不到示例.

The auto-fit outcome appears deliberate on Google's part - even though the effect is very different to the effect of the manual "Wrap" adjustment. These are relatively new commands (at the time of writing) and there are very few examples to be found online.

我已将此问题作为功能问题提出来,我们将看看是否会产生该问题任何澄清和/或更改.

I've raised this as a feature issue and we'll see whether that generates any clarification and/or change.

这篇关于Google表格setRowHeight()自动调整,不会调整为设置值的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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