在 Google 表单提交中显示 link 以下载您的格式化回复

On Google Form submit show a link to download your formatted response

我有一个表格,填写后会将回复添加到电子表格中。我还有一个脚本可以接受您的回复并将您的信息转换为 md 格式。我希望用户在 "Thank you page" 上提交表单后显示 link 以下载 md 格式的回复。 不知道如何将格式化的响应保存到 Drive I believe 以及如何显示 link 以下载此文件。任何 help/examples 表示赞赏。

请参阅下面的示例如何

  • 将表单回复转换为 html 文档
  • 将文档保存在驱动器上并获取下载link
  • 将下载 link 包含在表单提交时向提交者显示的确认消息中

To convert the form response to md instead of html, you need to either write a manual function or use a third-party API

样本:

function myFunction() {  
 var form = FormApp.getActiveForm();
 var length= form.getResponses().length;
 var lastResponse=  form.getResponses()[length-1].getItemResponses();
 var html="<html><body><table>";
 for(var i=0;i<lastResponse.length;i++){
    html+="<tr><td>"+lastResponse[i].getItem().getTitle()+"</td><td>"+lastResponse[i].getResponse()+"</td></tr>";
  }
 html+="</table></body></html>";
 var id=DriveApp.createFile("response"+length+".html", html).getId();
 var url=Drive.Files.get(id).webContentLink;
 form.setConfirmationMessage("Thank you filling out this form. This is the download link to your form response in html. Please wait 30 seconds before downloading, while the data is still being written into the file. "+url);
}

To make this script work

有用的参考资料: