2017-04-10 143 views
0

我想通過使用谷歌腳本刪除谷歌電子表格中的特定行。我創建了單獨的html頁面,以便插入行ID。但是,當我運行程序時,出現此錯誤。 {「result」:「error」,「error」:{「message」:「找不到方法deleteRow((class))。」,「name」:「InternalError」,「fileName」:「Code」 「LINENUMBER」:52, 「堆疊」: 「\ TAT編碼:52(用handleResponse)\ n \ TAT編碼:18(的doGet)\ n」}}使用谷歌腳本刪除電子表格數據

Here is my source code and I have created java script file in the same folder and external html file 引用 - https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/

回答

0

這將刪除一行。

function drow() 
{ 
    var sht=SpreadsheetApp.getActiveSheet(); 
    var response = SpreadsheetApp.getUi().prompt('Delete Row', 'Enter Row Number to Delete', SpreadsheetApp.getUi().ButtonSet.OK); 
    var rownum = Number(response.getResponseText()); 
    sht.deleteRow(rownum); 
} 
+0

謝謝你的回答,它工作正常。但我需要通過html網頁刪除它。而不是在腳本編輯器中運行腳本。有什麼辦法,我可以通過HTML網頁做到這一點。? – dara

+0

[HTML服務:與服務器功能通信google.script.run是一個異步客戶端JavaScript API,它允許HTML服務頁面調用服務器端Apps腳本函數。](https://developers.google.com/apps -script /引導件/ HTML /通信) – Cooper

相關問題