Docx to Google Doc using Google Script

橙三吉。 提交于 2020-01-17 03:45:13

问题


I have a lot of docx files ( ~ 72 ) , their MIMETYPE is :

application/vnd.openxmlformats-officedocument.wordprocessingml.document 

and I want to convert all of them to GoogleDocument so I can edit them online to do so I need them to be

application/vnd.google-apps.document

Is this possible ? I've tried with blob but nothing works , there is a way to create a new google doc with the same format ?


回答1:


Got it .

var docx = DriveApp.getFileById("###");
var newDoc = Drive.newFile();
var blob =docx.getBlob();
var file=Drive.Files.insert(newDoc,blob,{convert:true});

The {convert:true} convert it .

Ps : you need to set document name since it's not included in teh blob

DocumentApp.openById(file.id).setName(docx.getName());


来源:https://stackoverflow.com/questions/30615415/docx-to-google-doc-using-google-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!