這個問題在這里已經有了答案: 使用帶有索引和新名稱的“copyTo”將作業表從一個電子表格復制到另一個電子表格? (2 個回答) 5 小時前關閉。
我正在嘗試從活動電子表格中更改另一個電子表格中 google 選項卡的索引(選項卡)順序。當我使用 openById 運行日志時,我可以看到另一個電子表格和具有正確索引的選項卡,即 13:
Logger.log(SpreadsheetApp.openById('123456789').getSheetByName('sheet_name').getIndex());
Output: 10:00:39 AM Info 13.0
如何將索引從 13 移動到 1?我嘗試使用 .moveTo(n) 函式,如下所示:
SpreadsheetApp.openById('123456789').getSheetByName('sheet_name').moveTo(1);
但它拋出這個錯誤:
10:04:33 AM Error TypeError: SpreadsheetApp.openById(...).getSheetByName(...).moveTo is not a function update_SLA_SS @ Code.gs:106
有誰知道如何更改標簽索引?
謝謝!
uj5u.com熱心網友回復:
-我使用了谷歌表記錄宏,我得到了這個代碼:
- 似乎只有函式 moveActiveSheet(), moveTo() 不存在
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('sheet2'), true);
spreadsheet.moveActiveSheet(1);
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/365204.html
