Windows 上の PHP5 から Crystal Reports 11 コンポーネントに日付パラメーターを渡す際に、かなりの問題があります。もちろん簡単なはずですが、コメントアウトされたさまざまな項目が機能しないようです。
<?php
$my_report = "C:\\xampp\htdocs\wincare\laporan\adm_JumlahPasienPoli.rpt"; // rpt source file
$my_pdf = "C:\\xampp\htdocs\wincare\laporan\adm_JumlahPasienPoli.pdf"; // RPT export to pdf file
//-Create new COM object-depends on your Crystal Report version
$ObjectFactory= new COM("CrystalReports115.ObjectFactory.1") or die ("Error on load"); // call COM port
$crapp = $ObjectFactory-> CreateObject("CrystalDesignRunTime.Application.11"); // create an instance for Crystal
$creport = $crapp->OpenReport($my_report,1); // call rpt report
// to refresh data before
//- Set database logon info - must have
$creport->Database->Tables(1)->SetLogOnInfo("localhost", "db_wincare", "sa", "sa");
//- field prompt or else report will hang - to get through
$creport->EnableParameterPrompting = 0;
// this is the error
$zz = $creport->ParameterFields(1)->SetCurrentValue("2011-01-01 00:00:00");
//export to PDF process
$creport->ExportOptions->DiskFileName=$my_pdf; //export to pdf
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1; // export to file
$creport->ExportOptions->FormatType=31; // PDF type
$creport->Export(false);
//------ Release the variables ------
$creport = null;
$crapp = null;
$ObjectFactory = null;
//------ Embed the report in the webpage ------
print "<embed src=\"adm_JumlahPasienPoli.pdf\" width=\"100%\" height=\"100%\">"
?>
そしてメッセージ:
Fatal error: Uncaught exception 'com_exception' with message ' Source:
Description: ' in C:\xampp\htdocs\wincare\laporan\pakai.php:36 Stack trace: #0 C:\xampp\htdocs\wincare\laporan\pakai .php(36): variant->SetCurrentValue('2011-01-01 00:0...') #1 {main} が C:\xampp\htdocs\wincare\laporan\pakai.php 行 36 でスローされました