【问题标题】:I need help in mapping the web app to google spreadsheet我需要帮助将网络应用映射到谷歌电子表格
【发布时间】:2017-10-10 19:36:03
【问题描述】:

我需要创建一个网络应用程序,该应用程序将读取我的 google 电子表格列,并记录是否引用该单元格执行操作。

我有六列: 高级编号 |员工编号|电话号码 |发卡 |发行日期 |颁发者。

我想要应用程序中的一个搜索字段,用户可以在其中输入员工 ID,如果列表中提到了它,那么应用程序应该继续,否则错误“找不到”。

如果列表中提到了,用户将点击“提交”等按钮,然后会自动更新卡发行中的“是”、发行日期和发行者-电子邮件ID等详细信息。此链接应该可以访问特定域的所有用户,而不是公开的。

我尝试了许多网站上提供的许多代码,但我无法通过它。我非常需要完成这项工作。任何帮助将不胜感激。

这是我的工作表:https://docs.google.com/spreadsheets/d/17ctc5KUeg8qzWN3CD442cSVYpT1gjG4L_6AsBffnhes/edit?usp=sharing

我需要类似附图的东西。

enter image description here

【问题讨论】:

    标签: google-apps-script webapp2


    【解决方案1】:

    这会给你一个开始。只要您付出一点努力,您应该能够自己完成其余的工作。

    要运行它,您需要:

    使用给定的文件名将代码复制到脚本编辑器。拯救他们。运行 showEmployeeSearchDialog() 函数,它将启动 html。随着您的进步,您应该能够添加一个 doGet 函数并部署为 web 应用程序。

    代码.gs:

    function goFind(id) 
    {
      var ss=SpreadsheetApp.getActive();
      var sh=ss.getSheetByName('Master');
      var rg=sh.getDataRange();
      var vA=rg.getValues();
      var found=false;
      var dA=[];
      for(var i=1;i<vA.length;i++)
      {
        if(vA[i][1]==id)
        {
          dA.push(vA[i][0],vA[i][1],vA[i][2],vA[i][3],vA[i][4],vA[i][5]);
        }
      }
      return dA;
    }
    
    function showEmployeeSearchDialog()
    {
      var ui=HtmlService.createHtmlOutputFromFile('empsearchform');
      SpreadsheetApp.getUi().showModelessDialog(ui, 'Employee Search Form')
    }
    

    empsearchform.html

    <!DOCTYPE html>
    <html>
      <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script>
        $(function() {
    
          });
        function goFind()
        {
          var id=$('#txt1').val();
          $('#notfound').css('display','none');
          google.script.run
            .withSuccessHandler(found)
            .goFind(id);
        }
        function found(dA)
        {
          if(dA.length>0)
          {
            $('#hdn1').val(dA[0]);
            $('#txt2').val(dA[2]);
            $('#txt3').val(dA[3]);
            $('#txt4').val(dA[4]);
            $('#txt5').val(dA[5]);
            $('#found').css('display','inline');
          }
          else
          {
            $('#notfound').css('display','inline');
          }
        }
        function goUpdate()
        {
    
        }
        console.log('MyCode');
        </script>
      </head>
      <body>
      <br /><input type="text" placeholder="Enter Employee ID" id="txt1" size="15" />
      <br /><input type="button" value="Find" onClick="goFind()" />  
      <div id="found" style="display:none;">
      <br />Mobile Number:<input type="text" value="" size="" id="txt2" />
      <br />Card Issued:<input type="text" value="" size="" id="txt3" />
      <br />Date:<input type="text" value="" size="" id="txt4" />
      <br />Issued By:<input type="text" value="" size="" id="txt5" />
      <br /><input type="hidden" value="" id="hdn1" />
      <br /><input type="button" value="Submit" onClick="goUpdate()" />
      </div>
      <div id='notfound' style="display:none;"><br /><br />Employee ID not found.  Reenter Employee ID and push Find to try again.</div>
      </body>
    </html>
    

    这是当前对话框的样子:

    【讨论】:

      猜你喜欢
      • 2014-05-14
      • 2016-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 2019-02-12
      相关资源
      最近更新 更多