Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 通过Google应用程序脚本获取Google drive中文件的下载链接_Google Apps Script_Google Sheets_Google Drive Api - Fatal编程技术网

Google apps script 通过Google应用程序脚本获取Google drive中文件的下载链接

Google apps script 通过Google应用程序脚本获取Google drive中文件的下载链接,google-apps-script,google-sheets,google-drive-api,Google Apps Script,Google Sheets,Google Drive Api,我创建了一个脚本,如下所示: function myFunction() { let u1 = Drive.Files.get('1234'); // console.log() let u2 = DriveApp.getFileById('1234').getDownloadUrl(); let u3 = DriveApp.getFileById('1234').getUrl(); } id为1234的文件是Google drive中的电子表格 我想要一个链接 https://doc

我创建了一个脚本,如下所示:

function myFunction() {
 let u1 = Drive.Files.get('1234');
 // console.log()
 let u2 = DriveApp.getFileById('1234').getDownloadUrl();
 let u3 = DriveApp.getFileById('1234').getUrl();
}
id为1234的文件是Google drive中的电子表格

我想要一个链接

https://docs.google.com/spreadsheets/d/1234/export?format=xlsx
除非id不变,否则此链接似乎是静态的。 不过,我想知道一种使用file对象的方法来创建此链接的方法

我以为
u2
有链接,但它变成了
null
。 而
u3
is
https://docs.google.com/spreadsheets/d/1234/edit?usp=drivesdk

u1
似乎有链接,我实际上可以通过

u1.exportLinks["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];

这是获取链接的唯一方法吗?

关于
我想知道一种使用file对象的方法来获取此链接的方法。
,不幸的是,现在没有像
https://docs.google.com/spreadsheets/d/1234/export?format=xlsx
在这种情况下,
https://docs.google.com/spreadsheets/d/${fileId}/export?format=xlsx
是否使用文件ID?顺便说一下,about
u1似乎有链接,在本例中,URL类似于
https://docs.google.com/spreadsheets/export?id=###&exportFormat=xlsx
。这是你想要的URL吗?