如何使用驱动 API 和 GAS 将电子表格发布到网络 [英] how to publish to the web a spreadsheet using drive API and GAS
本文介绍了如何使用驱动 API 和 GAS 将电子表格发布到网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我激活了驱动 API (V2),并尝试将文件发布到网络
I activate the drive API, (V2), and I try to publish to the web a file
我尝试以下方法,但显然我错过了一些东西(资源).有人可以帮助我吗?非常感谢提前
I try the following, but obviously, I miss something (the resource). Can somebody help me? many thanks in advance
function test(){
var fileId = '1c5fRpKAk2YdUVzCa1LOCqDgTLZmYjsfSvTzR9BSGPYo';
var revisions = Drive.Revisions.list(fileId);
var items = revisions.items;
var revisionId = items[items.length-1].id;
var resource;
Drive.Revisions.update( resource , fileId, revisionId).published = true;
}
推荐答案
几个月后,我们得到了解决方案!
several months later, we got the solution !!
//this function publish to the web the document given by ID (google sheets or docs)
function publishToWeb(){
var fileId = 'WqcTq4c3iumeEUSgPMCcM8yKUqycQsrn_w3XeE';
var revisions = Drive.Revisions.list(fileId);
var items = revisions.items;
var revisionId =items[items.length-1].id;
var resource = Drive.Revisions.get(fileId, revisionId);
resource.published = true;
resource.publishAuto = true;
resource.publishedOutsideDomain = true;
Drive.Revisions.update(resource, fileId, revisionId);
}
这篇关于如何使用驱动 API 和 GAS 将电子表格发布到网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文