0
javascriptを使用してスプレッドシート内のscript is shared to organize sheetsという古いヘルプフォームを見つけました。次のようにスクリプトは次のとおりです。Googleスプレッドシート:スプレッドシート内のシートをアルファベット順に並べ替え
function copyAllSheetsToAnotherSpreadsheetInAlphabeticalOrder() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceName = ss.getName();
var sourceSheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
var targetName = "Sheets alphabetized - Copy of " + sourceName;
var sheetNumber, sourceSheet, sheetName;
var sheetAlphaArray = new Array();
// create a new empty target spreadsheet
var targetSpreadsheet = SpreadsheetApp.create(targetName);
var targetUrl = targetSpreadsheet.getUrl();
// iterate through all sheets in the source spreadsheet to collect their names and numbers
for(sheetNumber = 0; sheetNumber < sourceSheets.length; sheetNumber++) {
sheetAlphaArray[sheetNumber] = new Array(2);
sheetName = sourceSheets[sheetNumber].getName();
// we will sort the array by the sheet name so it needs to be the first element
sheetAlphaArray[sheetNumber][0] = sheetName;
// need to keep track of sheet numbers so that we can find the sheets
// in alphabetical order from the sourceSheets array, place it in the second element
sheetAlphaArray[sheetNumber][1] = sheetNumber;
}
// sort the sheet names array in ascending alphabetic order
sheetAlphaArray.sort();
// iterate through all sheets in the source spreadsheet by sheet name in alphabetic order
//
// new sheets are always added to the first position, so the sheets need to be added
// last sheet first, first sheet last, otherwise they would appear in reverse order
for(sheetNumber = sourceSheets.length - 1; sheetNumber >= 0; sheetNumber--) {
// copy next sheet in reverse alphabetical order from the source spreadsheet to target spreadsheet
sourceSheet = sourceSheets[ (sheetAlphaArray[sheetNumber][1]) ];
sourceSheet.copyTo(targetSpreadsheet);
}
// done, tell user where to find the new spreadsheet
Browser.msgBox("Spreadsheet copied with sheets in alphabetical order. " +
"Target name: " + targetName + ". " +
"Target URL: " + targetUrl) + ".";
}
スクリプトを実行した後、いくつかのページがアルファベット順にソートされているように見えるが、ソートされたページをスクロールした後にソートされていないたくさんあります。最初の15個がソートされ、続いて21個がソートされます。