スプレッドシート更新

This commit is contained in:
ry.yamafuji 2025-12-07 18:38:04 +09:00
parent 099f4366ca
commit bf772ed9f4
5 changed files with 80 additions and 1 deletions

View File

@ -1,3 +1,55 @@
# gas-common-dev
Google Apps Scriptに関する共通ソース
Google Apps Scriptに関する共通ソース
## Develop
Google Apps Script (GAS) は通常ブラウザのエディタで書きますが、
VS Code でローカル開発 → GAS にデプロイ → ローカルである程度テストという流れも可能です。
#### GASの開発に必要なもの
* Node.js / npm
* Google アカウント
* clasp
* VS Code
#### 開発構築
```sh
# clasp をインストール
npm install -g @google/clasp
# GAS へのログイン
clasp login
# GASプロジェクトを作成する(JS)
mkdir gas-sample
cd gas-sample
clasp create --type standalone --title "Sample GAS Project"
# スプレッドシートの場合
clasp create --type sheets --title "My Sheet Project"
```
作成されたCode.jsにソースを書きます
Code.js
```js
function helloWorld() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.getRange(1, 1).setValue("Hello from JavaScript!");
}
```
GASにデプロイする
```sh
clasp push
# 強制
# clasp push --force
```
デプロイしたプロジェクトをスプレッドシートと紐づける必要があります
```sh
clasp create --type sheets --title "My Sheet Project"
```

16
gas-sample/.clasp.json Normal file
View File

@ -0,0 +1,16 @@
{
"scriptId": "1JhI9GMgJpjI-ogbtfOFYCRhlMd3NnlkQs6dNuvS0JwyuwMPG8Wct-OuM",
"rootDir": "",
"scriptExtensions": [
".js",
".gs"
],
"htmlExtensions": [
".html"
],
"jsonExtensions": [
".json"
],
"filePushOrder": [],
"skipSubdirectories": false
}

4
gas-sample/Code.js Normal file
View File

@ -0,0 +1,4 @@
function helloWorld() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.getRange(1, 1).setValue("Hello from JavaScript!");
}

View File

@ -0,0 +1,7 @@
{
"timeZone": "America/New_York",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
}

0
readme/gcs.md Normal file
View File