Last active
August 22, 2025 05:15
-
-
Save donma/674943535e87f507aff88cf916911c68 to your computer and use it in GitHub Desktop.
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 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