2017-10-10 36 views
0

我需要创建一个web应用程序,它将读取我的谷歌电子表格列,并且记录操作是否被引用到该单元格。我需要帮助将网络应用程序映射到谷歌电子表格

我有六列: Sr. No. | Emp ID |电话号码|卡发行|签发日期|由...发出。

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

如果在列表中提到,用户将点击一个按钮,如“提交”,并且发布卡中的YES,发布日期和发送者 - 电子邮件ID等详细信息应自动更新。这个链接应该可以访问特定域的所有用户,而不是公开的。

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

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

我需要这样的东西附加的图片。

enter image description here

回答

0

这会给你一个开始。只需要付出一点努力,你就可以自己完成剩下的工作。

要运行这个,你将需要:使用指定的文件名

复制代码,脚本编辑器。保存它们。运行showEmployeeSearchDialog()函数并启动html。随着您的进步,您应该能够添加doGet功能并将其部署为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> 

这里的对话框看起来像在本什么:

enter image description here

相关问题