Crystal Reports 11.5与PHP和MySQL
我不熟悉Crystal Reports,我使用的是Crystal Reports 11.5版 我的要求如下:Crystal Reports 11.5与PHP和MySQL,php,mysql,reporting-services,crystal-reports,Php,Mysql,Reporting Services,Crystal Reports,我不熟悉Crystal Reports,我使用的是Crystal Reports 11.5版 我的要求如下: 编程环境是PHP 数据库是MySQL 我想使用Crystal Report+PHP+MySQL生成PDF报告 目前,我正在使用COM对象使用PHP连接到Crystal Report,并且我能够生成一个示例静态PDF报告 我的主要任务是在PHP中通过从MySQL获取值来完成所有处理,并将值传递给Crystal Reports并生成PDF。我需要帮助来完成这项任务。如果有人能提供示例代码,那
$my_report = "E:\\xampp\\htdocs\\crystal\\Test1.rpt";
$my_pdf = "E:\\xampp\\htdocs\\crystal\\test.pdf";
$o_CrObjectFactory = new COM('CrystalReports11.ObjectFactory.1');
// Create the Crystal Reports Runtime Application.
$o_CrApplication =$o_CrObjectFactory->CreateObject("CrystalDesignRunTime.Application");
//------ Open your rpt file ------
$creport = $o_CrApplication->OpenReport($my_report, 1);
//------ Connect to DB2 DataBase ------
**this is the hard part where I am not able to complete connection to mysql**
$o_CrApplication->LogOnServer('which library','mlims','root','');
//------ Put the values that you want --------
$creport->RecordSelectionFormula="{parameter.id}='1'";
//------ This is very important. DiscardSavedData make a
// Refresh in your data -------
$creport->DiscardSavedData;
//------ Read the records :-P -------
$creport->ReadRecords();
//------ 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;
正如您在上面的代码中看到的,我需要连接Mysql服务器,这是我过去几天一直在尝试的。我在网上尝试了很多例子,但大多数都是针对SQL Server的,而不是MySQL。请按照以下步骤操作:
请参见感谢穆罕默德·穆扎姆的回复,但我想通过Php进行连接。我正在进行一个基于患者报告的项目,一旦报告通过php准备好,我将单击下载报告,它应该连接到Crystal report并以PDF格式下载$o_craplication->LogOnServer('哪个库','mlims','root','');请在php中尝试此方法,您只有连接问题,并且需要在窗口端进行一些配置才能使crystal reports正常工作。您实际上必须在PHPP中使用JDBC,请先尝试