使用Google脚本删除电子表格数据

时间:2017-04-10 23:19:45

标签: google-apps-script google-sheets

我正在尝试使用Google脚本删除Google电子表格中的特定行。我已经创建了单独的html页面以便在行id之间。但是当我运行程序时,我收到了这个错误。

{“result”:“error”,“error”:{“message”:“找不到方法deleteRow((class))。”,“name”:“InternalError”,“fileName”:“Code”, “lineNumber”:52,“stack”:“\ 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/

1 个答案:

答案 0 :(得分: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);
}