如何使用Google Apps脚本下载创建的csv文件? [英] How to download created csv file using Google Apps Script?
本文介绍了如何使用Google Apps脚本下载创建的csv文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Google Apps Script中创建了一个文件,如下所示:
I've created a file in Google Apps Script as follows
DocsList.createFile(
"test.csv",
"Row1Col1,Row1Col2 \r\n Row2Col1,RowCol2 \r\n Row3Col1,Row3Col2");
如何以编程方式下载(例如,通过弹出式下载对话框)?
How to download it programmatically (via a popup Download dialog for example) ?
推荐答案
请尝试使用 ContentService ,您可以触发下载,甚至通过 TextOutput.downloadAsFile方法设置文件名。您还可以设置返回数据的内容MIME类型,但仅限于预定义的枚举常量。请参阅其示例。
Try using ContentService, you can trigger a download and even set the file name via the TextOutput.downloadAsFile method. You can also set the content mime type of the returned data, though only to a predefined enum constant. See their examples.
这篇关于如何使用Google Apps脚本下载创建的csv文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文