Create!Formの出力体験や
1ヶ月間無料の試用はこちら
Create!Formは、Windows・Linux環境においてPHPから利用可能な帳票ツールです。
この記事では、PHPでPDF、HTML、Excel、印刷の帳票を出力する最も簡単なサンプルコードを紹介します。
運用要件に応じた出力形態を以下のタブメニューから選択してご覧ください。
まず、Create!Formを使ってExcel帳票を生成する手順を説明します。

3の、Create!Form Screenを呼び出すPHPサンプルコードを以下に記載します。
実行パラメーターに、作業ディレクトリ、スタイルファイル、出力ファイル名、入力データファイル名を設定し、Create!Form Expageを呼び出します。
<?php
/*Create!Form:実行ファイルの設定*/
$cfInstDir = "C:/Program Files (x86)/Infotec/CreateForm/12";
/*作業ディレクトリ*/
$cfworkdir = "C:/ProgramData/Infotec/CreateForm/12/work/sample/15_Excel帳票";
/*スタイルファイル*/
$stylefile = "O04_geppo.sty";
/*出力ファイル名(ディレクトリに書き込み権限必要)*/
$outputdir = $cfworkdir;
$outputfile = $outputdir."/O04_geppo.xlsx";
/*入力データファイル名*/
$datafile = $cfworkdir."/O04_geppo.csv";
/*Create!Form Expage実行*/
$execmd = "\"".$cfInstDir."/CExpage.exe\" -D".$cfworkdir." -s".$stylefile." -o".$outputfile." ".$datafile;
system($execmd, $ret);
echo("Return Code:".$ret.PHP_EOL);
?>
<?php
/*Create!Form:実行ファイルの設定*/
/*作業ディレクトリ*/
$cfworkdir = "/home/test/work";
/*スタイルファイル*/
$stylefile = "O04_geppo.sty";
/*出力ファイル名(ディレクトリに書き込み権限必要)*/
$outputdir = "/home/test/work";
$outputfile = "O04_geppo.xlsx";
/*入力データファイル名*/
$datafile = "/home/test/work/O04_geppo.csv";
/*Create!Form Expage実行*/
/*実行コマンドライン*/
$execmd = "cexpage -D".$cfworkdir." -s".$stylefile." -o".$outputdir."/".$outputfile." ".$datafile;
$cfret = 0;
$sysret = "";
/*実行*/
$sysret = system($execmd , $cfret);
if($cfret!=0){
/*Create!Form実行エラー*/
print("Error:".$cfret.PHP_EOL);
print("Command:".$execmd.PHP_EOL);
}else{
print("Success");
}
?>
このサンプルコードを実行すると、指定したディレクトリにExcel帳票「O04_geppo.xlsx」が作成されます。