2017-10-10 37 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

相關問題