我想創建一個腳本,我可以在其中添加行(在前一行中)我選擇一個單元格。
例如,我有一個 50 行的表格選項卡。如果我選擇第 32 行并啟動我的腳本,我想在第 32 行添加一個新行,最后在我的選項卡中有 51 行。
在網路上進行研究后,我沒有找到任何相關資訊。可能我不知道如何搜索,因為我是法國人,可能我用了不好的詞。
這是我的代碼的開始,但它不起作用......
function ajoutLigne(e) {
const classeur = SpreadsheetApp.getActiveSpreadsheet();
const feuille = classeur.getActiveSheet();
const ui = SpreadsheetApp.getUi();
var rowIndex = feuille.getRange(e).index();
Logger.log(rowIndex);
}
感謝您提前提供幫助
uj5u.com熱心網友回復:
嘗試:
function insertRow() {
const sheet = SpreadsheetApp.getActiveSheet()
const index = sheet.getActiveRange().getRow()
sheet.insertRowBefore(index)
}
這將獲取活動行的索引,并插入一個空白行。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/494458.html
標籤:谷歌应用脚本
