戻る      excel.php      graph.php      graph_gen.php     

《PHP言語 /excel.php》

<?php
require_once("Spreadsheet/Excel/Writer.php");
$objWb=new Spreadsheet_Excel_Writer();
$objWb->send("demand.xls");
$objSht=$objWb->addWorksheet("demand");
$f_title=$objWb->addFormat();
$f_title->setBold();
$f_title->setUnderline(1);
$f_title->setSize(14);
$objSht->write(0,0,mb_convert_encoding("Excelシートへの出力","SJIS","auto"),$f_title);
$objSht->write(1,0,100);
$objWb->close();
?>


《PHP言語 /graph.php》

<html>
<head>
<title>棒グラフの動的生成</title>
</head>
<body>
<h1 style="background:#cccccc">書籍売り上げ傾向(2005年第一四半期)</h1>
<img src="graph_gen.php" width="450" height="250" />
</body>
</html>


《PHP言語 /graph_gen.php》

<?php
require_once("jpgraph/jpgraph.php");
require_once("jpgraph/jpgraph_bar.php");

$objGrh = new Graph(450,250,"auto");
$objGrh->SetScale("textlin");
$objGrh->title->Set("Books Trend");
$objGrh->xaxis->title->Set("2005.4Q");
$objGrh->xaxis->title->Set("Quantity");

$data=array(array(350,200,280),array(295,150,290),array(315,180,220));
$objPlot[]=new BarPlot($data[0]);
$objPlot[]=new BarPlot($data[1]);
$objPlot[]=new BarPlot($data[2]);
$objPlot[0]->SetLegend('PHP');
$objPlot[1]->SetLegend('ASP.NET');
$objPlot[2]->SetLegend('JSP');
$objPlot[0]->SetFillColor('red@0.7');
$objPlot[1]->SetFillColor('blue@0.7');
$objPlot[2]->SetFillColor('green@0.7');

$objGbp=new GroupBarPlot($objPlot);
$objGbp->SetWidth(0.90);
$objGrh->Add($objGbp);
$objGrh->Stroke();
?>