gpt4 book ai didi

google-apps-script - 应用程序脚本强制谷歌表格中的特定行高

转载 作者:行者123 更新时间:2023-12-03 08:51:40 25 4
gpt4 key购买 nike

我无法在应用程序脚本中找到强制 Google 工作表中特定行高的方法。当我使用“.setRowHeight(rowPosition, height)”时,它总是自动调整行高以适应字体大小。但我希望它能满足我的需要,如图所示。感谢您的帮助。

来自此:
from this

我希望应用程序脚本看起来像这样。
to this

最佳答案

  • 您想要根据您设置的大小修改行高。
  • 您希望使用 Google Apps 脚本来实现此目的。

如果我的理解是正确的,这个答案怎么样?请将此视为多个答案之一。

在这个答案中,我使用了 Sheets API 的“updateDimensionProperties”。当您使用此脚本时,please enable Sheets API at Advanced Google services.

示例脚本:

function myFunction() {
var height = 200; // Please set the height as the unit of pixel.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1"); // or ss.getActiveSheet()
var resource = {requests: [{
updateDimensionProperties: {
properties: {pixelSize: height},
range: {sheetId: sheet.getSheetId(), startIndex: 2, endIndex: 3, dimension:"ROWS"},
fields:"pixelSize"
}}]};
Sheets.Spreadsheets.batchUpdate(resource, ss.getId());
}
  • 在本例中,startIndex: 2, endIndex: 3 表示第 3 行。

注意:

  • 如果您想修改列宽,请将dimension修改为COLUMNS

引用文献:

如果我误解了您的问题并且这不是您想要的方向,我深表歉意。

关于google-apps-script - 应用程序脚本强制谷歌表格中的特定行高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58620929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com