You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Google Sheets仪表板查看多个Google Forms的开闭状态?

在Google Sheets中批量监控Google Forms开闭状态的实现方法

一、准备监控表格

  • 创建一个Google Sheets工作表,命名为「表单状态监控」
  • 设置列标题:表单名称、表单链接/ID、开闭状态、当前响应数(可选)
  • 将所有Google Forms的名称和对应链接(或表单ID)填入前两列

二、编写Apps Script获取状态

  1. 打开工作表,点击顶部菜单栏「扩展程序」→「Apps Script」进入脚本编辑器
  2. 替换默认代码为以下脚本:
function updateFormStatus() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("表单状态监控");
  const data = sheet.getDataRange().getValues();
  
  // 从第二行开始遍历(跳过表头)
  for (let i = 1; i < data.length; i++) {
    const formInfo = data[i][1];
    let form;
    
    try {
      // 兼容表单链接和ID两种格式
      if (formInfo.includes("https://docs.google.com/forms/d/")) {
        const formId = formInfo.split("/d/")[1].split("/")[0];
        form = FormApp.openById(formId);
      } else {
        form = FormApp.openById(formInfo);
      }
      
      // 获取核心状态数据
      const isOpen = form.isAcceptingResponses();
      const responseCount = form.getResponses().length;
      
      // 写入表格
      sheet.getRange(i+1, 3).setValue(isOpen ? "开启" : "关闭");
      sheet.getRange(i+1, 4).setValue(responseCount);
    } catch (error) {
      sheet.getRange(i+1, 3).setValue("获取失败");
      console.log(`第${i+1}行表单处理错误: ${error.message}`);
    }
  }
  
  SpreadsheetApp.getActiveSpreadsheet().toast("状态更新完成", "提示", 5);
}
  1. 保存脚本,命名为「FormStatusMonitor」
  2. 首次运行时按照提示完成授权(需要允许脚本访问你的表单和表格)

三、设置自动定时刷新(可选)

如果需要自动更新状态,无需手动运行脚本:

  • 在脚本编辑器左侧点击「触发器」图标(时钟样式)
  • 点击「添加触发器」,配置参数:
    • 选择函数:updateFormStatus
    • 部署类型:「基于时间的触发器」
    • 时间驱动类型:根据需求选择,比如「小时计时器」→「每1小时」
    • 保存后脚本会自动按设定频率更新状态

四、使用说明

  • 手动更新:回到Google Sheets,点击顶部「扩展程序」→「Apps Script」→ 找到updateFormStatus函数点击运行
  • 「开闭状态」列会显示「开启」/「关闭」,「当前响应数」列显示已收到的响应量
  • 若显示「获取失败」,可检查表单链接/ID是否正确,或查看脚本编辑器的「日志」排查问题

内容的提问来源于stack exchange,提问作者Colin Smith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 09:52:23