0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

どうもAtsu1209です。
最近GASを勉強中なのでメモ程度にGASで翻訳する方法を書いていきます。

GAS

trans.gs
function trans(){
  let ss = SpreadsheetApp.openById("シートID");
  let sheet = ss.getSheetByName("シート1");

  for(let i = 1; i <= 5; i++){
    const text = sheet.getRange("A" + i).getValue();
    const val = sheet.getRange("B" + i);

    let trans = LanguageApp.translate(text,"en","ja");
    
    val.setValue(trans);
    
  }
}

ssはスプレッドシートID
sheetはシート名

for文でA1〜A5までの翻訳結果をB1〜B5に出力
LanguageApp.translateでGoogle翻訳を使う。

getActiveSheet使わんの?

getActiveSheetを使ってスプレッドシートを取得してもいいんですが
なんか動かなかったので直接ID入れて取得しています。

お わ り

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?