创建GoogleDoc并记录更改,但是,当我转换时,我得到一个空白文档docx。我做错了什么?
var doc_id = DocumentApp.create('Sample Document').getId();
var doc = DocumentApp.openById(doc_id);
var body = doc.getBody();
var rowsData = [['Plants', 'Animals'], ['Ficus', 'Goat'], ['Basil', 'Cat']];
body.insertParagraph(0,'test');
table = body.appendTable(rowsData);
var file = Drive.Files.get(fileId);
var url = 'https://docs.google.com/feeds/download/documents/export/Export?id=' + fileId + '&exportFormat=docx';
var options = {
headers: {
Authorization: "Bearer " + ScriptApp.getOAuthToken()
},
muteHttpExceptions: true
}
var response = UrlFetchApp.fetch(url, options);
var doc = response.getBlob();
DriveApp.createFile(doc).setName(file.title);
答案 0 :(得分:0)
问题已经解决了!它是在doc.save和Close();