Skip to content

Instantly share code, notes, and snippets.

@donma
Last active August 22, 2025 05:15
Show Gist options
  • Save donma/674943535e87f507aff88cf916911c68 to your computer and use it in GitHub Desktop.
Save donma/674943535e87f507aff88cf916911c68 to your computer and use it in GitHub Desktop.
/**
* 取得目前作用中的工作表名稱
*
* 使用方式:
* 在 Google Sheets 的儲存格中輸入公式 =GetCurrentSheetName()
* 就會顯示當前工作表的名稱。
* 此為 Chatgpt輔助生成的註解
*/
function GetCurrentSheetName() {
// 取得目前活躍的試算表
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// 取得目前正在使用(被選取)的工作表
var sheet = spreadsheet.getActiveSheet();
// 取得該工作表的名稱(字串)
var sheetName = sheet.getName();
// 回傳工作表名稱,會顯示在呼叫此函數的儲存格中
return sheetName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment