<?php
function runCrystal($my_report, $my_pdf){
//?? Create a new COM Object of Crytal Reports XI R2??
$ObjectFactory = new COM("CrystalReports.ObjectFactory.1");
//?? Create a instance of library Application ??-
$crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");
//?? Open your rpt file ??
$creport = $crapp->OpenReport($my_report, 1);
//$bank= $creport->ParameterFields(1)->SetCurrentValue("test"); //send parameter example
//?? Export to PDF ??-
$creport->ExportOptions->DiskFileName=$my_pdf;
$creport->ExportOptions->FormatType=31;
$creport->ExportOptions->DestinationType=1;
$creport->Export(false);
//?? Release the variables
$creport = null;
$crapp = null;
$ObjectFactory = null;
}
//??????????????????? Function ??????????
//runCrystal("???? Crystal Reports (.rpt)", "??????????? PDF");
runCrystal("C:\\AppServ\\www\\PHP_SQL_CTR\Reportday.rpt", "C:\\AppServ\\www\\PHP_SQL_CTR\Reportday.pdf"); //C:\\AppServ\\www\\cams\\tmp\Report2.pdf
echo "<iframe
src ='/PHP_SQL_CTR/Reportday.pdf' width='100%' height='100%'>
</iframe>";
exit();
?>
ผลเป็นแบบนี้ครับ แก้ยังไงดัครับ
Warning: (null)(): Invalid ProgID, GUID string, or Moniker: Invalid syntax in c:\appserv\www\php_sql_ctr\test_com.php on line 5
Fatal error: Call to a member function on a non-object in c:\appserv\www\php_sql_ctr\test_com.php on line 7