LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Friday, June 15, 2018

スプレッドシートのURLをsplit()してスプレッドシートのIDを抽出する


スプレッドシートのURL
https://docs.google.com/spreadsheets/d/ID/edit#gid=0

この中からIDにあたる部分だけを抽出する

たまにやるので書き残しておこうと思い



コード.gs
function get_ssid_from_ssurl(){
  var SS_URL = "https://docs.google.com/spreadsheets/d/ID/edit#gid=0";
  var SS_ID = SS_URL.split("/d/")[1].split("/")[0];
  Logger.log(SS_ID);
}
意訳
この機能がやること
スプレッドシートのURL
/d/で区切った1番目を/で区切った0番目
をログに出す




Latest post

Creating a template copier app in Google Apps Script

Introduction This article will show you a template copier application in Google Apps Script.  This application will automatically copy a t...