Last active
March 25, 2026 11:41
-
-
Save koki-h/c0d96ef32cbd306afb86f3c5d38e12f4 to your computer and use it in GitHub Desktop.
スプレッドシートの行データを参照し、領収書のフォーム形式(複数行が1レコード)で使うための式を生成するスクリプト
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
| # SHEET_NAMEシートの各行データから、領収書用の文字列をまとめて出力するスクリプトです。 | |
| # 出力結果をスプレッドシートにコピー&ペーストすると、別途用意した領収書の書式に差し込んで使えます。 | |
| # 宛名・住所・参照列・対象行は、先頭の定数を変更することで調整できます。 | |
| SHEET_NAME = '領収データ' #シート名 | |
| ONCHU_NAME = 'xxxxxxxxx' #御中の名前 | |
| ADDRESS = '○○○○○' #住所 | |
| OBJ_COL = 'A' #但し書き | |
| NAME_COL = 'B' #氏名 | |
| PRICE_COL = 'C' #金額 | |
| START_ROW = 3 #開始行 | |
| END_ROW = 16 #終了行 | |
| def receipt(i) | |
| bill=<<~BILL | |
| 領収書 | |
| #{ONCHU_NAME} 御中 | |
| = "¥" & '#{SHEET_NAME}'!#{PRICE_COL}#{i} & "ー" | |
| ="但し " & '#{SHEET_NAME}'!#{OBJ_COL}#{i} & "として" | |
| 令和 年 月 日 | |
| 上記金額正に領収いたしました | |
| 住所 #{ADDRESS} | |
| ="氏名 " & '#{SHEET_NAME}'!#{NAME_COL}#{i} | |
| BILL | |
| end | |
| START_ROW.upto(END_ROW) do |i| | |
| puts recipt(i) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment