2017-03-29 3 views
1

나는 아주 간단하게 뭔가를하려하지만, 이해하지 못합니다. Google 웹 앱을 만들고 싶습니다. 사용자가 텍스트를 작성하고 싶습니다. 버튼을 클릭하면 텍스트가 Google 시트로 이동합니다. 구글 웹 응용 프로그램의 다른 사용자가 버튼을 클릭, 그는웹 스크립트 앱을 사용하여 Google 시트에 데이터 쓰기

나의 가장 큰 문제는 구글 시트의 셀에 기록 된 것을 볼 수 있습니다 때

다음, 나는 또한 contrairy을하고 싶습니다 웹 앱과 시트 사이의 연결 방법 및 사용 방법을 모르겠습니다.

도와 주시겠습니까? 감사합니다.

+0

보기 [여기 (https://developers.google.com/apps-script/guides/html/reference/run) –

+0

[웹 애플리케이션] (https://developers.goog) le.com/apps-script/guides/web) 개요에 대한 좋은 시작입니다. [HTML 서비스 : HTML 작성 및 게재] (https://developers.google.com/apps-script/guides/html/) 및 [우수 사례] (https://developers.google.com/apps-script/) 가이드/html/모범 사례). 이 기사가 도움이 될지 모르겠지만 한 가지 더 많은 리소스가 있습니다. [간단한 웹 앱] (https://www.topcoder.com/blog/a-simple-webapp-using-google- apps-scripts /) –

답변

0

다음은 수정 된 검색 스크립트입니다. 텍스트를 입력하고 goto Spreadsheet라는 단어를 입력하십시오.

웹 앱으로 배포해야합니다.

CODE.GS

function doGet(e) { // main function 
 
    var template = HtmlService.createTemplateFromFile('index.html'); 
 
    return template.evaluate().setTitle('Search Drive').setSandboxMode(HtmlService.SandboxMode.IFRAME); 
 
} 
 

 
// Process the form 
 
function processForm(searchTerm) { 
 
    var resultToReturn; 
 
    resultToReturn = TextToSheet(searchTerm); 
 
    return resultToReturn; // return the results 
 
} 
 

 
function TextToSheet(searchTerm) { 
 
    var ss = SpreadsheetApp.getActiveSpreadsheet(); 
 
    SpreadsheetApp.getActiveSheet().getRange('A1').setValue(searchTerm); 
 
    
 
}

index.html을

<html> 
 
    <head> 
 
    <base target="_top"> 
 
    <script> 
 
     function displayMessage() { 
 
     var searchTerm; 
 
     searchTerm = document.getElementById('idSrchTerm').value; 
 
     console.log('searchTerm: ' + searchTerm); 
 
     google.script.run.withSuccessHandler(handleResults).processForm(searchTerm.replace("'","\'")); 
 
     } 
 
      
 
     
 
     function handleResults(results){ 
 
     var length=results.length; // total elements of results 
 
     } 
 

 

 
    </script> 
 
    </head> 
 
    <body><center><br/> 
 
    Input word to SpreadSheet: <input type="text" id="idSrchTerm" name="search"> 
 
    <input type="button" value="Submit" name="submitButton" onclick="displayMessage()"/> 
 
</center> 
 
    </body> 
 
</html>