This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function to move all files in a particular Google Drive folder to another folder | |
* @param {string} moveFromFolderId - the original Google Drive folder ID from which you want to move the files | |
* @param {string} moveToFolderId - the Google Drive folder ID to which you want to move the files | |
*/ | |
function moveAllFiles(moveFromFolderId, moveToFolderId) { | |
var moveFrom = DriveApp.getFolderById(moveFromFolderId); | |
var moveTo = DriveApp.getFolderById(moveToFolderId); | |
var files = moveFrom.getFiles(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//元の選択肢。 | |
var originalChoice = [ | |
'Choice1', | |
'Choice2', | |
'etc.' | |
]; | |
// 設定 | |
var numQuestion = 2; // 動的に変化させる質問の番号。配列なので0からカウント。0, 1, 2, ... | |
var textQuestion = 'Title of Item (form question)'; // 動的に変化させる質問のテキスト |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function to create a Google Spreadsheet in a particular Google Drive folder | |
* @param {Object} targetFolder - Google Drive folder object in which you want to place the spreadsheet | |
* @param {string} ssName - name of spreadsheet | |
* @return {string} ssId - spreadsheet ID of created spreadsheet | |
*/ | |
function createSpreadsheet_(targetFolder, ssName) { | |
var ssId = SpreadsheetApp.create(ssName).getId(); | |
var temp = DriveApp.getFileById(ssId); | |
targetFolder.addFile(temp); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create Google Spreadsheet sheet(s) from set(s) of header and value | |
* | |
* @param {Object} spreadsheet - Spreadsheet object to create sheet on | |
* @param {Array} dataSet - Array of formatted object containing data object(s) which should be in form of | |
* [ | |
* {'sheetName':{string}'sheetName0', 'sheetData':{Array}dataObject0}, | |
* {'sheetName':{string}'sheetName1', 'sheetData':{Array}dataObject1},... | |
* ] | |
* @param {string} prefix - Optional. Prefix to be added to title of each sheet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the maximum value in a designated column | |
* @param {sheet} sheet Target sheet | |
* @param {number} numCol Column number of target column | |
* @param {number} initialValue Initial value | |
* @return {number} max The largest number in target column | |
*/ | |
function getMax(sheet, numCol, initialValue) { | |
initialValue = initialValue || 0; | |
var data = sheet.getRange(2, numCol, sheet.getLastRow()-1).getValues(); // First row of sheet used as header row |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Script for the original Google App Script from which you want to export the script properties. | |
* Shows in the log the script properties in JSON-encoded object; use with scriptPropertiesImport() described below | |
*/ | |
function scriptPropertiesExport() { | |
var properties = JSON.stringify(PropertiesService.getScriptProperties().getProperties()); | |
Logger.log(properties); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Google App Script to check the iCalID of a specific Google Calendar event. | |
* You need to have access to the Google Calendar, as designated by the Google Calendar ID | |
*/ | |
function checkICalId() { | |
var calendarId = '[email protected]'; | |
var startTime = new Date('2020-01-18T17:15+0900'); | |
var endTime = new Date('2020-01-18T17:15+0900'); | |
var events = CalendarApp.getCalendarById(calendarId).getEvents(startTime, endTime); | |
for (var i = 0; i < events.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Delete all sheets in this spreadsheet except for the designated sheet IDs | |
* @param {Array} exceptionSheetIds [Optional] Array of sheet IDs to not delete | |
*/ | |
function deleteSheets(exceptionSheetIds) { | |
exceptionSheetIds = exceptionSheetIds || []; | |
const ss = SpreadsheetApp.getActiveSpreadsheet(); | |
const sheets = ss.getSheets(); | |
for (var i = 0; i < sheets.length; i++) { | |
var sheet = sheets[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RECORDING_SHEET_NAME = 'SHEET_NAME'; // Sheet name to record the timestamp. | |
const RECORDING_CELL = {'row': 2, 'column': 2}; // Row and column number of the cell to record the timestamp. | |
/** | |
* Automatic timestamp for the latest update on this spreadsheet. | |
*/ | |
function onEdit() { | |
var now = new Date(); | |
var timestamp = now.toISOString(); | |
SpreadsheetApp.getActiveSpreadsheet() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets the cells' height and width in pixels for the selected range in Google Spreadsheet in form of a 2-d JavaScript array; | |
* the array values are ordered in the same way as executing Range.getValues() | |
* @param {Object} activeSheet The active Sheet class object in Google Spreadsheet, e.g., SpreadsheetApp.getActiveSheet() | |
* @param {Object} activeRange The selected Range class object in Google Spreadsheet, e.g., SpreadsheetApp.getActiveRange() | |
*/ | |
function cellPixSizes(activeSheet, activeRange) { | |
var rangeStartCell = { 'row': activeRange.getRow(), 'column': activeRange.getColumn() }; | |
var cellValues = activeRange.getValues(); | |
var cellPixSizes = cellValues.map(function(row, rowIndex) { |
OlderNewer