javascript - 从 google-sheets 数据自动填充 google sheet 模板
问题描述
我想做与基本邮件合并相同的概念,但使用 2 个 google 表格。一个有输入,另一个要填充。模板:https ://docs.google.com/spreadsheets/d/1iArfClgEMfwKQbEV_irwIbVD72hNI0JWCgtlizZKaGg/edit?usp=sharing
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [
{name: "Invoice from selection", functionName: "generateInvoice"},
];
ss.addMenu("Invoice", menuEntries);
}
function generateInvoiceForRow(index) {
var templateid = "1iArfClgEMfwKQbEV_irwIbVD72hNI0JWCgtlizZKaGg"; // this is the template file id. You can find this in the URL of the google document template. For example, if your URL Looks like this: https://docs.google.com/document/d/1SDTSW2JCItWMGkA8cDZGwZdAQa13sSpiYhiH-Kla6VA/edit, THEN the ID would be 1SDTSW2JCItWMKkA8cDZGwZdAQa13sSpiYhiH-Kla6VA
var FOLDER_NAME = "NAME OF DESTINATION FOLDER"; // Enter the name of the folder where you want to save your new documents. for example, this could be "Output Folder".
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('inputs');
var invoice = ss.getSheetId("1iArfClgEMfwKQbEV_irwIbVD72hNI0JWCgtlizZKaGg")
if (index===1) }
else {
var Name = sheet.getRange('D' + index).getValue(),
Email = sheet.getRange('C' + index).getValue(),
Address = sheet.getRange('E' + index).getValue();
ss.getRangeByName('client').setValue(Name + ' ' + Email+ '\n' + Address);
appendToDoc(doc, newDoc)
var usernamefordoctitle = sheet.getRange(2, 1, 1, 1).getValues();
var newDoc = SpreadsheetApp.create(current row " +clientname");
var file = DriveApp.getFileById(newDoc.getId());
var folder = DriveApp.getFolderById("1BGzhaYlSIRn2yHOED-U4qO04MDZHmgOc"); // INSERT the destination folder ID. Once again, this can be found in the URL once you have the folder openned in your browser
folder.addFile(file)
for (var i in data){
var row = data[i];
;
doc.saveAndClose()
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [
{name: "Invoice from selection", functionName: "generateInvoice"},
];
ss.addMenu("Invoice", menuEntries);
}
function generateInvoiceForRow(index) {
var templateid = "1iArfClgEMfwKQbEV_irwIbVD72hNI0JWCgtlizZKaGg"; // this is the template file id. You can find this in the URL of the google document template. For example, if your URL Looks like this: https://docs.google.com/document/d/1SDTSW2JCItWMGkA8cDZGwZdAQa13sSpiYhiH-Kla6VA/edit, THEN the ID would be 1SDTSW2JCItWMKkA8cDZGwZdAQa13sSpiYhiH-Kla6VA
var FOLDER_NAME = "NAME OF DESTINATION FOLDER"; // Enter the name of the folder where you want to save your new documents. for example, this could be "Output Folder".
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('inputs');
var invoice = ss.getSheetId("1iArfClgEMfwKQbEV_irwIbVD72hNI0JWCgtlizZKaGg")
if (index===1) }
else {
var Name = sheet.getRange('D' + index).getValue(),
Email = sheet.getRange('C' + index).getValue(),
Address = sheet.getRange('E' + index).getValue();
ss.getRangeByName('client').setValue(Name + ' ' + Email+ '\n' + Address);
appendToDoc(doc, newDoc)
var usernamefordoctitle = sheet.getRange(2, 1, 1, 1).getValues();
var newDoc = SpreadsheetApp.create(current row " +clientname");
var file = DriveApp.getFileById(newDoc.getId());
var folder = DriveApp.getFolderById("1BGzhaYlSIRn2yHOED-U4qO04MDZHmgOc"); // INSERT the destination folder ID. Once again, this can be found in the URL once you have the folder openned in your browser
folder.addFile(file)
for (var i in data){
var row = data[i];
;
doc.saveAndClose()
newDoc.saveAndClose()
DriveApp.getFileById(docid).setTrashed(true);
}
ss.toast("Templates has been complied.);
}
}
解决方案
推荐阅读
- electron - 我怎么知道鼠标已经进入电子项目的窗口?
- python - DataFrame 问题(括号)
- javascript - 如何使用_id检查mLab中是否存在对象?
- r - 在 R 中使用“plot()”时出现乱线
- ajax - 使用ajax更新时无法从summernote获取价值
- python - 将图像划分为块
- javascript - 如果检测到颜色改变,Jquery会立即改变文本的颜色
- python - 如何将硒屏幕截图直接保存/上传到第三方?Discord/Imgur/其他 Python3
- amazon-web-services - AWS ECS DescribeContainerInstances 由于 accountId 不匹配而生成 InvalidParameterException
- sharepoint - Sharepoint 项目多级审批