Google apps script 在Google文档中,如何设置所有表格的所有行高度以匹配单元格内容大小?
我发现这个问题在这里得到了回答: 代码看起来正是我需要的:Google apps script 在Google文档中,如何设置所有表格的所有行高度以匹配单元格内容大小?,google-apps-script,google-docs,Google Apps Script,Google Docs,我发现这个问题在这里得到了回答: 代码看起来正是我需要的: 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.getTab
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);
}
}
}
在提供的示例文档中尝试时,显示错误“TypeError:table.getNumRows不是函数”
我试过各种各样的改变来描述一张又一张的表格,用不同的方法来获得没有运气的行
这几个月有什么想法出了问题,以及如何修复代码?修改点:
- 我认为您的问题是由于V8运行时。例如,当您禁用V8运行时并使用rhino运行时时,我认为
的错误将被删除,脚本将正常工作。但在当前阶段,我建议使用v8运行时SyntaxError:Unexpected identifier…
- 当我看到你的共享文档时,我还发现了以下脚本
及for (var table in tables) { for (var i=0; i < table.getNumRows(); i++){ Logger.log("Fantasctic!"); table.getRow(i).setMinimumHeight(1); } }
致:用于(表中的var表){ 对于(var i=0;i
或tables.forEach(table=>{ 对于(var i=0;i
注:tables.forEach(函数(表){ 对于(var i=0;i
- 在这种情况下,请确认是否在脚本编辑器中启用了V8运行时李>
- 我认为您的问题是由于V8运行时。例如,当您禁用V8运行时并使用rhino运行时时,我认为
的错误将被删除,脚本将正常工作。但在当前阶段,我建议使用v8运行时SyntaxError:Unexpected identifier…
- 当我看到你的共享文档时,我还发现了以下脚本
及for (var table in tables) { for (var i=0; i < table.getNumRows(); i++){ Logger.log("Fantasctic!"); table.getRow(i).setMinimumHeight(1); } }
致:用于(表中的var表){ 对于(var i=0;i
或tables.forEach(table=>{ 对于(var i=0;i
注:tables.forEach(函数(表){ 对于(var i=0;i
- 在这种情况下,请确认是否在脚本编辑器中启用了V8运行时李>
for each (var table in tables) { for (var i=0; i < table.getNumRows(); i++){ Logger.log("Fantasctic!"); table.getRow(i).setMinimumHeight(1); } }
for (var table in tables) { for (var i=0; i < table.getNumRows(); i++){ Logger.log("Fantasctic!"); table.getRow(i).setMinimumHeight(1); } }
tables.forEach(table => { for (var i=0; i < table.getNumRows(); i++){ Logger.log("Fantasctic!"); table.getRow(i).setMinimumHeight(1); } });
tables.forEach(function(table) { for (var i=0; i < table.getNumRows(); i++){ Logger.log("Fantasctic!"); table.getRow(i).setMinimumHeight(1); } });