Reputation: 21
I am trying google app script to import google spreadsheet data to google doc. I haven't found any help in checking the API. Is it possible to import data to doc? then how?
Upvotes: 0
Views: 2544
Reputation: 21
function createDocFromSheet(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.setActiveSheet(ss.getSheets()[2]);
var values = ss.getDataRange().getValues()
for(n=2;n<=values.length;++n){
var cell = sheet.getRange(n,3).getValue();
var row = sheet.getRange(n,2,1,5).getValues();
var newDoc = DocumentApp.create(cell);
var body = newDoc.getBody();
body.insertParagraph(0,row);
newDoc.saveAndClose();
}
}
Upvotes: 2