我在将日期参数传递给Windows上的PHP5的Crystal Reports 11组件时遇到很大麻烦。它应该是很容易的,当然,但各注释掉的项目似乎并不工作:从PHP到Crystal Report的传递日期参数
<?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%\">"
?>
和messege:
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} thrown in C:\xampp\htdocs\wincare\laporan\pakai.php on line 36
嘿,刚刚在回答你的PM之后发现了这个。 +1 :)(你可能希望超链接SitePoint线程来展示你所做的研究,并且说那些东西对你来说不起作用。) – halfer 2012-08-08 10:23:31
我没有一个解决方案,已经发布。但是,对于它的价值,你传递的数据是** second **参数,对吗?请记住,第一个参数可能是'$ creport-> ParameterFields(0)' – halfer 2012-08-09 08:30:09
(正如我在回答中所讨论的,我已经将最新的OP编辑回来了,编辑问题以询问另一个不是一个好的方法,因为现有的答案被置于背景之外,请问一个新的问题)。 – halfer 2012-08-13 11:20:59