【发布时间】:2020-10-01 15:36:48
【问题描述】:
我在这里找到了这个问题的答案: In a Google Document how to set a tables multiple rows' height to match the cell content size? 代码看起来正是我需要的:
function fixCellSize() {
DocumentApp.getUi().alert("All row heights will be minimized to content height.");
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var tables = body.getTables();
for each (var table in tables) {
for (var i=0; i < table.getNumRows(); i++){
Logger.log("Fantasctic!");
table.getRow(i).setMinimumHeight(1);
}
}
}
但它不再起作用了。 如果在文档中添加到我的脚本中,则在保存时显示错误:“SyntaxError: Unexpected identifier ...”并提及脚本中的行:
for each (var table in tables) {
在in the answer of that question 提供的示例文档中尝试时显示错误“TypeError: table.getNumRows is not a function”
我尝试了各种描述表格的改变,表格,不同的获取行的方法没有运气。
这几个月有什么想法出错了,如何修复代码?
【问题讨论】:
-
确切的错误是什么?
标签: google-apps-script google-docs