我需要帮助将网络应用程序映射到Google电子表格 [英] I need help in mapping the web app to google spreadsheet

查看:153
本文介绍了我需要帮助将网络应用程序映射到Google电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个Web应用程序,它将读取我的Google电子表格列,并记录引用该单元格的操作。

我有六列:
老号| Emp ID |电话号码|卡发行|签发日期|发布者。



我希望应用中的用户可以输入员工ID的搜索字段,如果在列表中提及,那么应用程序应该继续,否则错误可以找到。

如果在列表中提及,用户将点击一个按钮,如提交,以及详细信息,例如发卡中的YES,发行日期和发出者 - 电子邮件ID应自动更新。此链接应该可以访问特定域名的所有用户,而不是公开的。



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



以下是我的工作表:


I need to create a web app which will read my google spreadsheet column and also record if the action is taken referencing to that cell.

I have six columns: Sr. No. | Emp ID| Phone Number | Card Issued | Date of Issuance | Issued By.

I want a search field in the app where user can enter employee id and if it is mentioned in the list then app should proceed, else error "can't find".

If it is mentioned in the list, user will click on a button such as "Submit", and the details such as YES in Card issued, Date of issuance and in Issued By - email id should be automatically updated. This link should have access to all the users of specific domain and not public.

I have tried many codes available on many websites but I'm unable to get through it. I'm badly in need to complete this. Any help will be appreciated.

Here's my sheet: https://docs.google.com/spreadsheets/d/17ctc5KUeg8qzWN3CD442cSVYpT1gjG4L_6AsBffnhes/edit?usp=sharing

I need something like the attached picture.

enter image description here

解决方案

This will give you a start. With a little effort on your part you should be able to complete the rest on your own.

To run this you will need to:

Copy code to script editor using the given files names. Save them. Run the showEmployeeSearchDialog() function and that will launch the html. As you progress you should be able to add a doGet function and deploy as a webapp.

Code.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>

Here's what the dialog looks like at the present:

这篇关于我需要帮助将网络应用程序映射到Google电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆