Please see my spreadsheet.
I have a menu item, Create/Job Scope that pulls data from the spreadsheet and creates a new document in "my drive" location of google drive. Problem I have, is that it's not including the stye and format that I have in the spreadsheet. I have tried many ways of setting the variable in the script to "bold", for example, but can't seem to get it to work. I am hoping there is an object that I can add to the variable that will set it's style.
For example, in my script, I have a variable called "desc"
var descr = values[n][3] ;
I would like to just create a new variable such as
var descr = values[n][3] ;
var desc_style = descr.setStyle("bold") ;
Here is the script from the spreadsheet but I think it's best if you just update the script in my spreadsheet.
function jobScope() {
var ss = SpreadsheetApp.getActiveSheet();
var values = ss.getDataRange().getValues();
var docTemplate = "19ANrZluvbavWU4Ttgh1z9_DVJgEQ1hrGohd4lQAg7vI";
var job_name = ss.getRange("D4").getValue();
var docName = job_name+' Job Scope ';
var x = 1 ;
while(values[x][0] ^= "") {
++x ;
}
var textToDoc = "" ;
for(n=1;n<x;++n){
var cell = values[n][4] ;
if (cell ^ "0") {
var line_item = values[n][1];
var descr = values[n][3] ;
textToDoc = textToDoc + line_item + " " + descr + "\n\n" ;
}
}
var copyId = DocsList.getFileById(docTemplate)
.makeCopy(docName)
.getId();
var copyDoc = DocumentApp.openById(copyId);
var copyBody = copyDoc.getActiveSection();
copyBody.replaceText('keyScope', textToDoc);
copyBody.replaceText('keyJobName', job_name);
copyDoc.saveAndClose();
}