[英]What's wrong with my Google Spreadsheet Script?
I am trying to create a script to automatically take information from a google sheet and put each row of data into individual, formatted docs. 我正在尝试创建一个脚本,以自动从Google表格中获取信息,并将每一行数据放入单独的格式化文档中。 However when I run the script it either populates the data as "DOB" (in the date of birth spot) or as a different value. 但是,当我运行脚本时,它要么将数据填充为“ DOB”(在出生日期),要么填充为其他值。 I am not a very good programmer and any help is appreciated. 我不是一个很好的程序员,我们将不胜感激。 Thanks, 谢谢,
function createDocument() {
var headers =Sheets.Spreadsheets.Values.get('1oycOOxDIAhbAI6Yq54KF4GAnjfVcttywYXOpKDBLHag', ('A1', 'B1', 'C1', 'D1', 'H1', 'I1', 'N1', 'O1'));
var tactics = Sheets.Spreadsheets.Values.get('1oycOOxDIAhbAI6Yq54KF4GAnjfVcttywYXOpKDBLHag', ('A4:O14'));
var templateId = '1NJQHx4TWRQ3EQle5aLr-QV4uqD-tSR8TMP2-f6QjPmY';
for(var i = 0; i < tactics.values.length; i++){
var Patient_name = tactics.values[i][0];
var Date_Scheduled = tactics.values[i][0];
var Surgery_Posting = tactics.values[i][0];
var Start_Time = tactics.values[i][0];
var Hospital = tactics.values[i][0];
//Make a copy of the template file
var documentId = DriveApp.getFileById(templateId).makeCopy().getId();
//Rename the copied file
DriveApp.getFileById(documentId).setName(Patient_name + ' Surgery Posting');
//Get the document body as a variable
var body = DocumentApp.openById(documentId).getBody();
//Insert the Patient_name
body.replaceText('##Patient_name##', Patient_name)
//Insert the Date_Scheduled
body.replaceText('##Date_Scheduled##', Date_Scheduled)
//Insert the Surgery_Posting
body.replaceText('##Surgery_Posting##', Surgery_Posting)
//Insert the Start_Time
body.replaceText('##Start_Time##', Start_Time)
//Insert the Hospital
body.replaceText('##Hospital##', Hospital)
//Append tactics
parseTactics(headers.values[0], tactics.values[i], body);
}
}
function parseTactics(headers, tactics, body){
for(var i = 0; i < tactics.length; i++){
{tactics[i] != '' &&
body.appendListItem(headers[i] + ' | ' + tactics[i] + ' net').setGlyphType(DocumentApp.GlyphType.BULLET);
}
}
}
The column position after the iterator was not changed to the next column. 迭代器之后的列位置未更改为下一列。
var Patient_name = tactics.values[i][0];
var Date_Scheduled = tactics.values[i][1]; //this last part the 0 to 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.