0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

  1. テーマ:「データ型」について
    ・データ入力の自動化と計算の表示例について
    データ型の種類:数値型、文字列、真偽型、日付型

  2. データ取得から計算

・function makeExpenseReport() {
// シートを取得
let sheet = SpreadsheetApp.getActiveSheet();

// 費用データを取得
let trainFee = sheet.getRange("B4").getValue(); // 交通費
let foodFee = sheet.getRange("B5").getValue(); // 食費
let hotelFee = sheet.getRange("B6").getValue(); // 宿泊費

//合計の計算
let totalFee = trainFee+foodFee+hotelFee;

//税金の計算
let tax = totalFee * 0.1;
let totalWithTax = totalFee + tax;

//計算結果を書き込む
sheet.getRange ("B7").setValue(totalFee); // 合計(税抜)
sheet.getRange("B8").setValue(totalWithTax); // 税込合計

// 申請者の情報を取得
let name = sheet.getRange("B1").getValue() // 名前
let team = sheet.getRange("B2").getValue() // 部署

// 申請文を作る

let report =
"経費申請書" +"\n"+
"申請者"+ name + "("+ team + ")"+"\n"+
"合計金額"+totalWithTax+"円(税込)";

// 申請文を書き込む
sheet.getRange("A15").setValue(report);
}

  1. 気づき
    ・交通費はここではtrainFeeとなっていますが、transportationFeeとしてもちょっと長いができそう。
    ・「let」は「sheet.getRange・・・」の先頭には使わないこと
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?