google-apps-script - Google 电子表格 - 插入剪切/复制的单元格/行

标签 google-apps-script google-spreadsheet-api

谷歌电子表格没有像 Excel 那样“插入剪切单元格”的功能。

假设我选择了 A4 到 B5,按 Ctrl+X。
然后我将选择移到 A2。
现在我想“插入剪切单元格”,可能是通过插入空白单元格和 moving虚线范围到 A2。
screenshot

有什么办法可以在 your own menu 上使用 JavaScript 做到这一点吗? ?

例如。

function insertCutOrCopiedCells(){
  var SS = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = SS.getActiveSheet();
  var cell = sheet.getActiveCell();

  // How do you get the cells being cut/copied? (ie. A4 to B5)

  // We can then insert empty cells (2 cols 2 rows) at the selection (A2)
  // and move the cut cells (A4 to B5) there
}

最佳答案

要在 Google 表格中实现插入剪切单元格功能,您只需使用拖放操作。首先突出显示要移动的行,然后将鼠标悬停在行号上(您将看到 手形图标 );然后,按住左键单击并将鼠标悬停在行号上,您将看到一条黑线,插入将发生的位置。松开鼠标按钮,瞧。

enter image description here

关于google-apps-script - Google 电子表格 - 插入剪切/复制的单元格/行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29937294/

相关文章:

java - 使用 Java 将数据写入 Google 电子表格

google-apps-script - 出现错误 "The script completed but did not return anything."

javascript - 有什么方法可以更改应用程序脚本的用户代理吗?

javascript - 在 onEdit 触发器的事件对象中,如何将 range get 同时定义为实际范围对象和属性标识符?

javascript - 如何从 Google 表单提交触发器函数访问电子表格

google-sheets - Google Sheet API v4

javascript - 与谷歌脚本一起使用时,币安搜索 API 返回 403

javascript - Apps 脚本 - 丢失;声明之前

java - 在 Google 电子表格 : Blank rows cannot be written; use delete instead 中插入一行

google-sheets - 如何获取注释或评论