背景信息:我有一个程序可以为谷歌文档中的6至12年级学生和领导/教师创建照片目录。对于每个学生,它会插入一张图片,然后插入几行单独的文本(姓名,电话号码等)。在每个新成绩开始之前,插入文本以标记成绩(即6年级)。当转换到新成绩时(即所有6年级学生都在目录中,并且现在从7年级学生开始),将启动新页面并添加另一个标题以标记新成绩(即7年级) 。我想把它变成一个3列目录,页面上每列有4个学生。由于谷歌文档不允许我直接制作列,我相信我需要制作一个带有隐形/白色边框的表格。我想让每个页面成为一个4行x 3列表。有些年级有超过12名学生(一个4x3桌子值得),所以我需要继续在某些成绩的多个页面上。对于没有12名学生的页面,我需要将页面上剩余的单元格留空或者进行分页,以便新成绩在单独的页面上开始。
以下是主要问题:我如何"追加"图像和段落到表格中的特定单元格?我如何修改下面的代码,以便将学生的照片和多行信息插入表格单元格中,然后启动新的表格单元格?我尝试制作一个表格,在那里我可以作为数组的一部分访问每个单元格,然后将图像和段落附加到特定的单元格,但我无法弄清楚如何(下面没有包含错误的代码)。 / p>
对于广泛的代码感到抱歉。如果您需要澄清,请告诉我。谢谢!
var sheetID = "x"; //x = link
var GDoc = DocumentApp.openByUrl("y"); //y = link
var body = GDoc.getBody(); //google document body
function loadSheet() {
body.clear(); //deletes previous doc contents so a new photo directory can be made
//** Variables **//
//load studentSheet
var StudentSheet = SpreadsheetApp.openById(sheetID).getSheetByName('Students');
var studentdata = StudentSheet.getDataRange().getValues();
var PreviousGrade = "0"; //initially sets the previous grade to zero so that the first grade created will be different than the previous grade
//make variables to hold data from StudentSheet
for (var studentRowNumber = 1; studentRowNumber < studentdata.length; studentRowNumber++) { //studentdata.length determines speed of program execution
var FirstName = studentdata[studentRowNumber][1];
var LastName = studentdata[studentRowNumber][2];
var Gender = studentdata[studentRowNumber][3];
var School = studentdata[studentRowNumber][4];
var Grade = studentdata[studentRowNumber][5];
var Birthday = studentdata[studentRowNumber][6];
var MemberCellPhone = studentdata[studentRowNumber][7]; //student or leader cell phone
var MemberEmail = studentdata[studentRowNumber][8];
var DadFirstName = studentdata[studentRowNumber][9];
var MomFirstName = studentdata[studentRowNumber][10];
var DadLastName = studentdata[studentRowNumber][11];
var MomLastName = studentdata[studentRowNumber][12];
var DadEmail = studentdata[studentRowNumber][13];
var MomEmail = studentdata[studentRowNumber][14];
var DadCellPhone = studentdata[studentRowNumber][15];
var MomCellPhone = studentdata[studentRowNumber][16];
var HomePhone = studentdata[studentRowNumber][17];
var StreetAddress = studentdata[studentRowNumber][18];
var City = studentdata[studentRowNumber][19];
var ZipCode = studentdata[studentRowNumber][20];
var longpictureID = studentdata[studentRowNumber][21];
/** determines whether a page break should be inserted for a transition to the next grade **/
var CurrentGrade = Grade;
if (CurrentGrade !== PreviousGrade) { //new grade category
if (PreviousGrade !== "0") { //this is not the first grade category
GDoc.appendPageBreak();
}
if (PreviousGrade == "0") { //this is the first grade category
var LittleBlankLine = body.appendParagraph(""); //blank line inserted before first age category title to make things line up evenly on document with columns; modify as needed
}
if (CurrentGrade == "6" || CurrentGrade == "7" || CurrentGrade == "8") { //6-8th; || = or
var GradeCategory = "MS";
var GradeCategoryTitle = body.appendParagraph(GradeCategory);
var NewGradeTitle = body.appendParagraph("Grade " + CurrentGrade);
var BigBlankLine = body.appendParagraph("");
var SeparationLine = GDoc.appendParagraph("_________________________");
PreviousGrade = CurrentGrade;
}
if (CurrentGrade == "9" || CurrentGrade == "10" || CurrentGrade == "11" || CurrentGrade == "12") { //9-12th
var GradeCategory = "HS";
var GradeCategoryTitle = body.appendParagraph(GradeCategory);
var NewGradeTitle = body.appendParagraph("Grade " + CurrentGrade);
var BigBlankLine = body.appendParagraph("");
var SeparationLine = GDoc.appendParagraph("_________________________");
PreviousGrade = CurrentGrade;
}
if (CurrentGrade == "Leader") {
var GradeCategory = "Youth";
var GradeCategoryTitle = body.appendParagraph(GradeCategory);
var NewGradeTitle = body.appendParagraph("Leaders");
var BigBlankLine = body.appendParagraph("");
var SeparationLine = GDoc.appendParagraph("_________________________");
PreviousGrade = CurrentGrade;
}
GradeCategoryTitle.editAsText().setFontSize(36);
NewGradeTitle.editAsText().setFontSize(36);
var LittleBlankLine = body.appendParagraph(""); //blank line
BigBlankLine.editAsText().setFontSize(36);
SeparationLine.editAsText().setFontSize(7);
}
//** Inserting Picture of Student into Google Doc **//
//verify if there is a picture uploaded for the student, and if there is then insert it in the google doc
if (longpictureID !== "") { //there is an uploaded picture
var shortpictureID = longpictureID.replace('https://drive.google.com/uc?export=view&id=', '');
//(old, new); replace all occurences of old with new in string
}
else { //there is not an uploaded picture
shortpictureID = "0B5kYlCqpy3BBX2M4M2dWVWEzcjA"; //pic of a silhoutte
}
//insert image from drive
var img = DriveApp.getFileById(shortpictureID).getBlob();
var inlineI = GDoc.appendImage(img);
//resizing the image
var width = inlineI.getWidth();
var newW = width;
var height = inlineI.getHeight();
var newH = height;
var ratio = width/height;
//this makes the images all the same height
newH = 60;
newW = parseInt(newH/(1/ratio));
inlineI.setWidth(newW).setHeight(newH);
//** insert student info into google doc **//
var FullName = body.appendParagraph(FirstName + " " + LastName); //combine student's first and last names
//verify that both parents' names are present
if (DadFirstName == "" && MomFirstName !== "") {
//if dad's name is missing
var ParentsText = body.appendParagraph("Parents: " + MomFirstName);
}
else {
if (DadFirstName !== "" && MomFirstName == "") {
//if mom's name is missing
var ParentsText = body.appendParagraph("Parents: " + DadFirstName);
}
else {
if (DadFirstName == "" && MomFirstName == "") {
//if both parent names are missing
var ParentsText = body.appendParagraph("Parents: ");
}
else {
//both parent names are given
var ParentsText = body.appendParagraph("Parents: " + DadFirstName + " & " + MomFirstName);
}
}
}
//verify that birthday is given
if (Birthday !== "") { //birthday is given
var BirthdayText = body.appendParagraph("Birthday: " + Birthday);
}
else { //no birthday is given
var BirthdayText = body.appendParagraph("Birthday: ");
}
//verify that grade is given
if (Grade !== "") {
if (Grade == "Leader") { //this is a leader
var GradeText = body.appendParagraph("Role: " + Grade);
}
else { //this is a student
var GradeText = body.appendParagraph("Grade: " + Grade);
}
}
else { //no grade is given
var GradeText = body.appendParagraph("Grade: ");
}
//determine whether this is a student or leader, and if student then verify that both parents' phone numbers are present
if (Grade == "Leader" && MemberCellPhone !== "") { //this is a leader and he/she has a cellphone
var CellTextLabel = body.appendParagraph("Phone: "); //label
var MemberCellText = body.appendParagraph(MemberCellPhone); //leader's cell phone number
var DadCellText = "";
var MomCellText = "";
//extra blank line is added for email
}
else { //this is a student
if (DadCellPhone == "" && MomCellPhone !== "") {
//dad's name is missing
var CellTextLabel = body.appendParagraph("Phone: ");
var MomCellText = body.appendParagraph(" Mom - " + MomCellPhone);
var LittleBlankLine = body.appendParagraph(""); //blank line
var MemberCellText = "";
var DadCellText = "";
}
else {
if (DadCellPhone !== "" && MomCellPhone == "") {
//mom's name is missing
var CellTextLabel = body.appendParagraph("Phone: ");
var DadCellText = body.appendParagraph(" Dad - " + DadCellPhone);
var LittleBlankLine = body.appendParagraph(""); //blank line
var MemberCellText = "";
var MomCellText = "";
}
else {
if (DadCellPhone == "" && MomCellPhone == "") {
//both parent names are missing
var CellTextLabel = body.appendParagraph("Phone: None");
var LittleBlankLine = body.appendParagraph("");
var LittleBlankLine = body.appendParagraph("");
var MemberCellText = "";
var DadCellText = "";
var MomCellText = "";
}
else {
//both parent names are given
var CellTextLabel = body.appendParagraph("Phone: ");
var DadCellText = body.appendParagraph(" Dad - " + DadCellPhone);
var MomCellText = body.appendParagraph(" Mom - " + MomCellPhone);
var MemberCellText = "";
}
}
}
}
//verify that both parents' emails are present
if (Grade == "Leader" && MemberEmail !== "") { //this is a leader and he/she has an email
var EmailTextLabel = body.appendParagraph("Email: "); //leader's email
var MemberEmailText = body.appendParagraph(" " + MemberEmail);
var LittleBlankLine = body.appendParagraph("");
var LittleBlankLine = body.appendParagraph(""); //extra blank line for leader email, because there is one less blank line for phone
var DadEmailText = "";
var MomEmailText = "";
}
else { //this is a student
if (DadEmail == "" && MomEmail !== "") {
//dad's name is missing
var EmailTextLabel = body.appendParagraph("Email: ");
var MomEmailText = body.appendParagraph(" Mom - " + MomEmail);
var LittleBlankLine = body.appendParagraph("");
var DadEmailText = "";
var MemberEmailText = "";
}
else {
if (DadEmail !== "" && MomEmail == "") {
//mom's name is missing
var EmailTextLabel = body.appendParagraph("Email: ");
var DadEmailText = body.appendParagraph(" Dad - " + DadEmail);
var LittleBlankLine = body.appendParagraph("");
var MomEmailText = "";
var MemberEmailText = "";
}
else {
if (DadEmail == "" && MomEmail == "") {
//both parent names are missing
var EmailTextLabel = body.appendParagraph("Email: None");
var LittleBlankLine = body.appendParagraph("");
var LittleBlankLine = body.appendParagraph("");
var DadEmailText = "";
var MomEmailText = "";
var MemberEmailText = "";
}
else {
//both parent names are given
var EmailTextLabel = body.appendParagraph("Email: ");
var DadEmailText = body.appendParagraph(" Dad - " + DadEmail);
var MomEmailText = body.appendParagraph(" Mom - " + MomEmail);
var MemberEmailText = "";
}
}
}
}
//** modify text attributes **//
if (FullName !== "") {
FullName.editAsText().setBold(false).setFontSize(9).setForegroundColor('#000066'); //black
}
if (ParentsText !== "") {
ParentsText.editAsText().setFontSize(7).setForegroundColor(0, 8, '#FF0000'); //red
}
if (BirthdayText !== "") {
BirthdayText.editAsText().setFontSize(7).setForegroundColor(0, 9, '#FF0000');
}
if (GradeText !== "") {
if (Grade == "Leader") { //this is a leader
GradeText.editAsText().setFontSize(7).setForegroundColor(0, 5, '#FF0000');
}
else { //this is a student
GradeText.editAsText().setFontSize(7).setForegroundColor(0, 6, '#FF0000');
}
}
if (CellTextLabel !== "") {
CellTextLabel.editAsText().setFontSize(7).setForegroundColor(0, 6, '#FF0000'); //makes first 6 characters red ("Phone:")
}
if (MemberCellText !== "") {
MemberCellText.editAsText().setFontSize(7).setForegroundColor('#000066'); //black
}
if (DadCellText !== "") {
DadCellText.editAsText().setFontSize(7).setForegroundColor('#000066');
}
if (MomCellText !== "") {
MomCellText.editAsText().setFontSize(7).setForegroundColor('#000066');
}
if (EmailTextLabel !== "") {
EmailTextLabel.editAsText().setFontSize(7).setForegroundColor(0, 6, '#FF0000'); //student's email, red
}
if (MemberEmailText !== "") {
MemberEmailText.editAsText().setFontSize(7).setForegroundColor('#000066'); //black
}
if (DadEmailText !== "") {
DadEmailText.editAsText().setFontSize(7).setForegroundColor('#000066');
}
if (MomEmailText !== "") {
MomEmailText.editAsText().setFontSize(7).setForegroundColor('#000066');
}
//if (LittleBlankLine !== null) { //not sure if this conditional works
LittleBlankLine.editAsText().setFontSize(7);
//}
var SeparationLine = GDoc.appendParagraph("_________________________");
SeparationLine.editAsText().setFontSize(7);
GDoc.appendParagraph("");
}
}
答案 0 :(得分:0)
我实际上找到了解决问题的方法,虽然我不确定它是否是最有效的问题。以下是代码,以防任何人使用:
var sheetID = "x"; //link
var GDoc = DocumentApp.openByUrl("y"); //link
var body = GDoc.getBody(); //google document body
body.clear(); //deletes previous doc contents so a new photo directory can be made
function loadSheet() {
var CurrentBoxNumber = 1;
var CurrentBox = 1;
//** Variables **//
//load studentSheet
var StudentSheet = SpreadsheetApp.openById(sheetID).getSheetByName('Students');
var studentdata = StudentSheet.getDataRange().getValues();
var PreviousGrade = "0"; //initially sets the previous grade to zero so that the first grade created will be different than the previous grade
//make variables to hold data from StudentSheet
for (var studentRowNumber = 1; studentRowNumber < studentdata.length; studentRowNumber++) { //studentdata.length determines speed of program execution
var FirstName = studentdata[studentRowNumber][1];
var LastName = studentdata[studentRowNumber][2];
var Gender = studentdata[studentRowNumber][3];
var School = studentdata[studentRowNumber][4];
var Grade = studentdata[studentRowNumber][5];
var Birthday = studentdata[studentRowNumber][6];
var MemberCellPhone = studentdata[studentRowNumber][7]; //student or leader cell phone
var MemberEmail = studentdata[studentRowNumber][8];
var DadFirstName = studentdata[studentRowNumber][9];
var MomFirstName = studentdata[studentRowNumber][10];
var DadLastName = studentdata[studentRowNumber][11];
var MomLastName = studentdata[studentRowNumber][12];
var DadEmail = studentdata[studentRowNumber][13];
var MomEmail = studentdata[studentRowNumber][14];
var DadCellPhone = studentdata[studentRowNumber][15];
var MomCellPhone = studentdata[studentRowNumber][16];
var HomePhone = studentdata[studentRowNumber][17];
var StreetAddress = studentdata[studentRowNumber][18];
var City = studentdata[studentRowNumber][19];
var ZipCode = studentdata[studentRowNumber][20];
var longpictureID = studentdata[studentRowNumber][21];
/** determines whether a page break should be inserted for a transition to the next grade **/
var CurrentGrade = Grade;
if (CurrentGrade !== PreviousGrade) { //new grade category
if (PreviousGrade !== "0") { //this is not the first grade category
GDoc.appendPageBreak();
var table = body.appendTable();
var Row1 = table.appendTableRow();
var Row1Cell1 = Row1.appendTableCell();
}
if (PreviousGrade == "0") { //this is the first grade category
var table = body.appendTable();
var Row1 = table.appendTableRow();
var Row1Cell1 = Row1.appendTableCell();
//var LittleBlankLine = Row1Cell1.appendParagraph(""); //blank line inserted before first age category title to make things line up evenly on document with columns; modify as needed
//Row1Cell1
}
if (CurrentGrade == "6" || CurrentGrade == "7" || CurrentGrade == "8") { //6-8th; || = or
var GradeCategory = "MS";
var GradeCategoryTitle = Row1Cell1.appendParagraph(GradeCategory);
var NewGradeTitle = Row1Cell1.appendParagraph("Grade " + CurrentGrade);
var BigBlankLine = Row1Cell1.appendParagraph("");
//var SeparationLine = Row1Cell1.appendParagraph("_________________________");
PreviousGrade = CurrentGrade;
CurrentBoxNumber = 2;
}
if (CurrentGrade == "9" || CurrentGrade == "10" || CurrentGrade == "11" || CurrentGrade == "12") { //9-12th
var GradeCategory = "HS";
var GradeCategoryTitle = Row1Cell1.appendParagraph(GradeCategory);
var NewGradeTitle = Row1Cell1.appendParagraph("Grade " + CurrentGrade);
var BigBlankLine = Row1Cell1.appendParagraph("");
//var SeparationLine = Row1Cell1.appendParagraph("_________________________");
PreviousGrade = CurrentGrade;
CurrentBoxNumber = 2;
}
if (CurrentGrade == "Leader") {
var GradeCategory = "Youth";
var GradeCategoryTitle = Row1Cell1.appendParagraph(GradeCategory);
var NewGradeTitle = Row1Cell1.appendParagraph("Leaders");
var BigBlankLine = Row1Cell1.appendParagraph("");
//var SeparationLine = Row1Cell1.appendParagraph("_________________________");
PreviousGrade = CurrentGrade;
CurrentBoxNumber = 2;
}
GradeCategoryTitle.editAsText().setFontSize(36);
NewGradeTitle.editAsText().setFontSize(36);
//var LittleBlankLine = Row1Cell1.appendParagraph(""); //blank line
BigBlankLine.editAsText().setFontSize(7); //36
//SeparationLine.editAsText().setFontSize(7);
}
/** 1 5 9
2 6 10
3 7 11
4 8 12
**/
if (CurrentBoxNumber == 1) {
var table = body.appendTable();
var Row1 = table.appendTableRow();
var Row1Cell1 = Row1.appendTableCell();
var CurrentBox = Row1Cell1;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 2) {
var Row2 = table.appendTableRow();
var Row2Cell1 = Row2.appendTableCell();
var CurrentBox = Row2Cell1;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 3) {
var Row3 = table.appendTableRow();
var Row3Cell1 = Row3.appendTableCell();
var CurrentBox = Row3Cell1;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 4) {
var Row4 = table.appendTableRow();
var Row4Cell1 = Row4.appendTableCell();
var CurrentBox = Row4Cell1;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 5) {
var Row1Cell2 = Row1.appendTableCell();
var CurrentBox = Row1Cell2;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 6) {
var Row2Cell2 = Row2.appendTableCell();
var CurrentBox = Row2Cell2;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 7) {
var Row3Cell2 = Row3.appendTableCell();
var CurrentBox = Row3Cell2;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 8) {
var Row4Cell2 = Row4.appendTableCell();
var CurrentBox = Row4Cell2;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 9) {
var Row1Cell3 = Row1.appendTableCell();
var CurrentBox = Row1Cell3;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 10) {
var Row2Cell3 = Row2.appendTableCell();
var CurrentBox = Row2Cell3;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 11) {
var Row3Cell3 = Row3.appendTableCell();
var CurrentBox = Row3Cell3;
Logger.log(CurrentBox);
}
if (CurrentBoxNumber == 12) {
var Row4Cell3 = Row4.appendTableCell();
var CurrentBox = Row4Cell3;
Logger.log(CurrentBox);
}
//** Inserting Picture of Student into Google Doc **//
//verify if there is a picture uploaded for the student, and if there is then insert it in the google doc
if (longpictureID !== "") { //there is an uploaded picture
var shortpictureID = longpictureID.replace('https://drive.google.com/uc?export=view&id=', '');
//(old, new); replace all occurences of old with new in string
}
else { //there is not an uploaded picture
shortpictureID = "0B5kYlCqpy3BBX2M4M2dWVWEzcjA"; //pic of a silhoutte
}
//insert image from drive
var img = DriveApp.getFileById(shortpictureID).getBlob();
var inlineI = CurrentBox.appendImage(img);
//resizing the image
var width = inlineI.getWidth();
var newW = width;
var height = inlineI.getHeight();
var newH = height;
var ratio = width/height;
//this makes the images all the same height
newH = 60;
newW = parseInt(newH/(1/ratio));
inlineI.setWidth(newW).setHeight(newH);
//** insert student info into google doc **//
var FullName = CurrentBox.appendParagraph(FirstName + " " + LastName); //combine student's first and last names
//verify that both parents' names are present
if (DadFirstName == "" && MomFirstName !== "") {
//if dad's name is missing
var ParentsText = CurrentBox.appendParagraph("Parents: " + MomFirstName);
}
else {
if (DadFirstName !== "" && MomFirstName == "") {
//if mom's name is missing
var ParentsText = CurrentBox.appendParagraph("Parents: " + DadFirstName);
}
else {
if (DadFirstName == "" && MomFirstName == "") {
//if both parent names are missing
var ParentsText = CurrentBox.appendParagraph("Parents: ");
}
else {
//both parent names are given
var ParentsText = CurrentBox.appendParagraph("Parents: " + DadFirstName + " & " + MomFirstName);
}
}
}
//verify that birthday is given
if (Birthday !== "") { //birthday is given
var BirthdayText = CurrentBox.appendParagraph("Birthday: " + Birthday);
}
else { //no birthday is given
var BirthdayText = CurrentBox.appendParagraph("Birthday: ");
}
//verify that grade is given
if (Grade !== "") {
if (Grade == "Leader") { //this is a leader
var GradeText = CurrentBox.appendParagraph("Role: " + Grade);
}
else { //this is a student
var GradeText = CurrentBox.appendParagraph("Grade: " + Grade);
}
}
else { //no grade is given
var GradeText = CurrentBox.appendParagraph("Grade: ");
}
//determine whether this is a student or leader, and if student then verify that both parents' phone numbers are present
if (Grade == "Leader" && MemberCellPhone !== "") { //this is a leader and he/she has a cellphone
var CellTextLabel = CurrentBox.appendParagraph("Phone: "); //label
var MemberCellText = CurrentBox.appendParagraph(MemberCellPhone); //leader's cell phone number
var DadCellText = "";
var MomCellText = "";
//extra blank line is added for email
}
else { //this is a student
if (DadCellPhone == "" && MomCellPhone !== "") {
//dad's name is missing
var CellTextLabel = CurrentBox.appendParagraph("Phone: ");
var MomCellText = CurrentBox.appendParagraph(" Mom - " + MomCellPhone);
var LittleBlankLine = CurrentBox.appendParagraph(""); //blank line
var MemberCellText = "";
var DadCellText = "";
}
else {
if (DadCellPhone !== "" && MomCellPhone == "") {
//mom's name is missing
var CellTextLabel = CurrentBox.appendParagraph("Phone: ");
var DadCellText = CurrentBox.appendParagraph(" Dad - " + DadCellPhone);
var LittleBlankLine = CurrentBox.appendParagraph(""); //blank line
var MemberCellText = "";
var MomCellText = "";
}
else {
if (DadCellPhone == "" && MomCellPhone == "") {
//both parent names are missing
var CellTextLabel = CurrentBox.appendParagraph("Phone: None");
var LittleBlankLine = CurrentBox.appendParagraph("");
var LittleBlankLine = CurrentBox.appendParagraph("");
var MemberCellText = "";
var DadCellText = "";
var MomCellText = "";
}
else {
//both parent names are given
var CellTextLabel = CurrentBox.appendParagraph("Phone: ");
var DadCellText = CurrentBox.appendParagraph(" Dad - " + DadCellPhone);
var MomCellText = CurrentBox.appendParagraph(" Mom - " + MomCellPhone);
var MemberCellText = "";
}
}
}
}
//verify that both parents' emails are present
if (Grade == "Leader" && MemberEmail !== "") { //this is a leader and he/she has an email
var EmailTextLabel = CurrentBox.appendParagraph("Email: "); //leader's email
var MemberEmailText = CurrentBox.appendParagraph(" " + MemberEmail);
var LittleBlankLine = CurrentBox.appendParagraph("");
var LittleBlankLine = CurrentBox.appendParagraph(""); //extra blank line for leader email, because there is one less blank line for phone
var DadEmailText = "";
var MomEmailText = "";
}
else { //this is a student
if (DadEmail == "" && MomEmail !== "") {
//dad's name is missing
var EmailTextLabel = CurrentBox.appendParagraph("Email: ");
var MomEmailText = CurrentBox.appendParagraph(" Mom - " + MomEmail);
var LittleBlankLine = CurrentBox.appendParagraph("");
var DadEmailText = "";
var MemberEmailText = "";
}
else {
if (DadEmail !== "" && MomEmail == "") {
//mom's name is missing
var EmailTextLabel = CurrentBox.appendParagraph("Email: ");
var DadEmailText = CurrentBox.appendParagraph(" Dad - " + DadEmail);
var LittleBlankLine = CurrentBox.appendParagraph("");
var MomEmailText = "";
var MemberEmailText = "";
}
else {
if (DadEmail == "" && MomEmail == "") {
//both parent names are missing
var EmailTextLabel = CurrentBox.appendParagraph("Email: None");
var LittleBlankLine = CurrentBox.appendParagraph("");
var LittleBlankLine = CurrentBox.appendParagraph("");
var DadEmailText = "";
var MomEmailText = "";
var MemberEmailText = "";
}
else {
//both parent names are given
var EmailTextLabel = CurrentBox.appendParagraph("Email: ");
var DadEmailText = CurrentBox.appendParagraph(" Dad - " + DadEmail);
var MomEmailText = CurrentBox.appendParagraph(" Mom - " + MomEmail);
var MemberEmailText = "";
}
}
}
}
//** modify text attributes **//
if (FullName !== "") {
FullName.editAsText().setBold(false).setFontSize(9).setForegroundColor('#000066'); //black
}
if (ParentsText !== "") {
ParentsText.editAsText().setFontSize(7).setForegroundColor(0, 8, '#FF0000'); //red
}
if (BirthdayText !== "") {
BirthdayText.editAsText().setFontSize(7).setForegroundColor(0, 9, '#FF0000');
}
if (GradeText !== "") {
if (Grade == "Leader") { //this is a leader
GradeText.editAsText().setFontSize(7).setForegroundColor(0, 5, '#FF0000');
}
else { //this is a student
GradeText.editAsText().setFontSize(7).setForegroundColor(0, 6, '#FF0000');
}
}
if (CellTextLabel !== "") {
CellTextLabel.editAsText().setFontSize(7).setForegroundColor(0, 6, '#FF0000'); //makes first 6 characters red ("Phone:")
}
if (MemberCellText !== "") {
MemberCellText.editAsText().setFontSize(7).setForegroundColor('#000066'); //black
}
if (DadCellText !== "") {
DadCellText.editAsText().setFontSize(7).setForegroundColor('#000066');
}
if (MomCellText !== "") {
MomCellText.editAsText().setFontSize(7).setForegroundColor('#000066');
}
if (EmailTextLabel !== "") {
EmailTextLabel.editAsText().setFontSize(7).setForegroundColor(0, 6, '#FF0000'); //student's email, red
}
if (MemberEmailText !== "") {
MemberEmailText.editAsText().setFontSize(7).setForegroundColor('#000066'); //black
}
if (DadEmailText !== "") {
DadEmailText.editAsText().setFontSize(7).setForegroundColor('#000066');
}
if (MomEmailText !== "") {
MomEmailText.editAsText().setFontSize(7).setForegroundColor('#000066');
}
//if (LittleBlankLine !== null) { //not sure if this conditional works
LittleBlankLine.editAsText().setFontSize(7);
//}
//var SeparationLine = CurrentBox.appendParagraph("_________________________");
//SeparationLine.editAsText().setFontSize(7);
//CurrentBox.appendParagraph("");
table.setBorderColor('#FFFFFF').setBorderWidth(0); //white border
if (CurrentBoxNumber == 12) {
CurrentBoxNumber = 1;
}
else { //less than 12
CurrentBoxNumber++;
}
}
}