我想在Google表格电子表格中编写一些保护措施,以保持网页的正确顺序。我无法保护整个工作表不被修改,因为它是用于组织的组工作簿..组织:P
在google脚本中,我找到了getIndex,但我需要一个setIndex
这是代码的骨架,以防我不清楚
function resetSheetPos() {
var s = SpreadsheetApp.getActiveSheet();
if s.getSheetName() = "Instructions" {
//the function I can't find would look like this
//s.setIndex(0);
s.activate(); // in case we aren't still looking at the same sheet when it changed it's index
};
if s.getSheetName() = "Notes and Comments" {
//and would be incremented for each sheet
//s.setIndex(1);
s.activate(); //again only if needed.
};
// and so on for each sheet
};
答案 0 :(得分:1)
您需要在父电子表格上使用方法而不是直接使用表格。
请参阅moveActiveSheet(index),或者可能是insertSheet(index)
https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#moveActiveSheet(Integer)