Is it possible to have a small script that will re-arrange the order of the sheet tabs moving the currently selected sheet tab to the far left (the beginning) of all the tabs in a Google Spreadsheet?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes and No. It can be done by sweet name, but not by the current sheet you are looking at. Below is some code I wrote that moves a sweet to the first position every day.
function tab() {
var reportDate = new Date();
var tabName = Utilities.formatDate(reportDate, 'MST', 'yyyy-MM-dd').toString();
var tab = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tabName);
SpreadsheetApp.setActiveSheet(tab);
SpreadsheetApp.getActiveSpreadsheet().moveActiveSheet(1);
}
回答2:
function BacktotheFront() {
SpreadsheetApp.getActiveSpreadsheet().moveActiveSheet(1);
}
回答3:
This adds two menu items in a menu called "Move Tabs" which will move the current tab to either the far left or far right.
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Move Tabs')
.addItem('Move Current Sheet To Far Left', 'moveCurrentToFarLeft')
.addItem('Move Current Sheet To Far Right', 'moveCurrentToFarRight')
.addToUi();
}
function moveCurrentToFarRight() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheets = spreadsheet.getSheets();
spreadsheet.moveActiveSheet(sheets.length);
}
function moveCurrentToFarLeft() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
spreadsheet.moveActiveSheet(1);
}