使用Google Script将Google Doc转换为Docx [英] Convert Google Doc to Docx using Google Script
本文介绍了使用Google Script将Google Doc转换为Docx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用Google脚本以编程方式将Google文档转换为Word docx文件?
Is it possible to convert a Google document to a Word docx file programmatically using Google Script ?
推荐答案
这应该有效
function myFunction() {
var token = ScriptApp.getOAuthToken();
//Make sure to replace the correct file Id
// Fetch the docx blob
var blb = UrlFetchApp.fetch('https://docs.google.com/feeds/download/documents/export/Export?id=<ID_of_Google_Document>&exportFormat=docx',
{
headers : {
Authorization : 'Bearer '+token
}
}).getBlob();
//Create file in Google Drive
var file = DriveApp.createFile(blb).setName('<name_of_exported_file>.docx');
//Put the file in a drive folder
DriveApp.getFolderById('<FOLDER_ID>').addFile(file);
}
这篇关于使用Google Script将Google Doc转换为Docx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文