[英]Download PDF file from google drive AppScript Google Sheet
I created a button in google sheets and I'm trying to download file from google drive with ID that I store in a cell.我在 google 表格中创建了一个按钮,我正在尝试从 google 驱动器下载文件,其中的 ID 存储在一个单元格中。 I searched stackoverflow and I found some code that might work, but it doesn't.
我搜索了 stackoverflow,我发现了一些可能有效的代码,但它没有。 When I assign the script to the button and I click it, it says "We're sorry, a server error occurred. Please wait a bit and try again."
当我将脚本分配给按钮并单击它时,它会显示“很抱歉,发生服务器错误。请稍等一下,然后重试。”
That's the code I'm trying to use:那是我要使用的代码:
function doGet(e) {
return HtmlService.createHtmlOutput(downloader());
}
function downloader() {
var mySheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("File Lookup");
var File_LinkID = mySheet.getRange("J4").getValue();
var out = "<body onload='dllink.click()'>";
out +="<a id='dllink' href='https://drive.google.com/uc?export=download&id="+File_LinkID+"'>wait will download automatically<a/>";
out +="</body>";
return out;
};
Thank you!谢谢!
In your situation, how about the following modification?在您的情况下,以下修改如何?
out +="<a id='dllink' href='https://drive.google.com/uc?export=download&id="+File_LinkID+"'>wait will download automatically<a/>";
out +="<a id='dllink' target='_blank' href='https://drive.google.com/uc?export=download&id="+File_LinkID+"'>wait will download automatically<a/>";
target='_blank'
is added.target='_blank'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.