;============================================================ ; iron_report.hsp — HTML テンプレート帳票出力モジュール ; ; HTML テンプレートにデータを差し込んで帳票を生成し、 ; ブラウザで印刷プレビュー表示する。 ; ; API: ; report_init 初期化 ; report_template html_str テンプレート設定 ; report_set "key", "value" 差し込みデータ設定 ; report_table_begin "key" テーブル行の開始 ; report_table_row "col1", "col2",... テーブル行追加 ; report_table_end テーブル行の終了 ; report_generate HTML 生成 → refstr ; report_preview ブラウザで表示 ; report_save "file.html" ファイル保存 ; ; テンプレート内の {{key}} が report_set の値に置換される。 ; {{TABLE:key}} は report_table_row の内容に展開される。 ; ; 例: ; #include "iron_report.hsp" ; report_init ; report_template {" ; ;

請求書

;

顧客名: {{customer}}

;

日付: {{date}}

; ; ; {{TABLE:items}} ;
品名数量金額
;

合計: {{total}}円

; ; "} ; report_set "customer", "山田太郎" ; report_set "date", "2026/04/16" ; report_table_begin "items" ; report_table_row "りんご", "3", "450" ; report_table_row "みかん", "5", "500" ; report_table_end ; report_set "total", "950" ; report_preview ;============================================================ #ifndef __iron_report_hsp__ #define __iron_report_hsp__ #module iron_report sdim _tmpl, 65536 sdim _vars_key, 256, 100 sdim _vars_val, 4096, 100 _vars_count = 0 sdim _tbl_key, 256 sdim _tbl_rows, 65536 _tbl_active = 0 #deffunc report_init _tmpl = "" _vars_count = 0 _tbl_active = 0 sdim _tbl_rows, 65536 return #deffunc report_template str html _tmpl = html return #deffunc report_set str key, str value ; 既存キーの上書きチェック repeat _vars_count if _vars_key(cnt) == key { _vars_val(cnt) = value return } loop _vars_key(_vars_count) = key _vars_val(_vars_count) = value _vars_count++ return #deffunc report_table_begin str key _tbl_key = key _tbl_rows = "" _tbl_active = 1 return #deffunc report_table_row str c1, str c2, str c3, str c4, str c5, str c6, str c7, str c8 _tbl_rows += "" if c1 != "" : _tbl_rows += "" + c1 + "" if c2 != "" : _tbl_rows += "" + c2 + "" if c3 != "" : _tbl_rows += "" + c3 + "" if c4 != "" : _tbl_rows += "" + c4 + "" if c5 != "" : _tbl_rows += "" + c5 + "" if c6 != "" : _tbl_rows += "" + c6 + "" if c7 != "" : _tbl_rows += "" + c7 + "" if c8 != "" : _tbl_rows += "" + c8 + "" _tbl_rows += "\n" return #deffunc report_table_end report_set "TABLE:" + _tbl_key, _tbl_rows _tbl_active = 0 return #defcfunc report_generate local html, local i html = _tmpl ; {{key}} → value の置換 repeat _vars_count i = cnt strrep html, "{{" + _vars_key(i) + "}}", _vars_val(i) loop return html #deffunc report_preview local html, local tmpfile html = report_generate() tmpfile = dir_cur + "\\__iron_report_tmp.html" notesel html notesave tmpfile exec tmpfile, 16 return #deffunc report_save str filepath, local html html = report_generate() notesel html notesave filepath return #global #endif