javascript - 错误:TypeError:doc.saveAndClose 不是函数
问题描述
当我运行我的代码时,我遇到了错误“错误:TypeError:doc.saveandClose 不是函数”。我无法在我的编码中发现错误:
function myFunction() {
const ui = SpreadsheetApp.getUi();
const menu = ui.createMenu('AutoFill Docs');
menu.addItem('Create New Docs', 'CreateNewGoogleDocs')
menu.addToUi();
}
function CreateNewGoogleDocs() {
const googleDocTemplate = DriveApp.getFileById("1sFPHjQZiwpby0MP_fWmd4-Xkb6rsfcNzXFyaTQrDERU");
const destinationFolder = DriveApp.getFolderById("10z_aBfhd0J4F5qx9O1T2EGIKAnLCYrf6");
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Mail Merge');
const rows = sheet.getDataRange().getValues();
rows.forEach(function(row, index) {
if (index === 0) return;
const copy = googleDocTemplate.makeCopy(`${row[1]}, Developer Details`, destinationFolder);
const doc = DocumentApp.openById(copy.getId())
const body = doc.getBody();
body.replaceText('{{Developer Name}}', row[0]);
doc.saveAndClose();
const url = doc.getUrl();
sheet.getRange(index + 1, 9).setValue(url)
})
}
解决方案
推荐阅读
- android - Intent.ACTION_SEND 找不到 Whatsapp
- vue.js - Match path-string to Vue Router params
- apache - 如何获取 PHP 智能 URL
- java - 为什么平衡 BST 中节点值之和的时间复杂度为 O(n)?
- docker - 在构建类似于bubble.io 的网站构建器时,我需要一个建议
- cordova - 用于浏览器的 Razorpay cordova 插件
- php - foreach 循环内的多维数组
- c++ - 如何在 C++ 中打开文件资源管理器对话框?
- google-sheets - 谷歌表格连续反转值(不排序)
- r - dplyr:计算汇总组之间的百分比变化