Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Crystal Reports 11.5与PHP和MySQL_Php_Mysql_Reporting Services_Crystal Reports - Fatal编程技术网

Crystal Reports 11.5与PHP和MySQL

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。我需要帮助来完成这项任务。如果有人能提供示例代码,那

我不熟悉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。

    请按照以下步骤操作:

  • 下载MySQL jar文件。该下载应包含一个类似以下内容的jar文件: mysql-connector-java-3.1.14-bin.jar

  • 按照CrystalReports CRConfig.xml文件中的定义,将新下载的jar文件的位置添加到类路径中。在Windows计算机上,配置文件将位于以下位置: C:\Program Files\Business Objects\Common\3.5\java\CRConfig.xml

  • 更改CRConfig.xml后,请关闭并重新打开Crystal Reports

  • 从菜单:文件->新建->标准报告
  • 在“可用数据源”列表中,双击展开“创建新连接”
  • 双击展开“JDBC(JNDI)”
  • 双击“建立新连接”
  • 连接URL:“jdbc:mysql://db.example.com/dbname“(使用您自己的数据库主机名和数据库名)。 数据库类名:“com.mysql.jdbc.Driver”
  • 单击“下一步”
  • 出现提示时输入数据库用户/密码组合
  • 现在,您应该能够检查数据库中的表/列以开始报告


    请参见

    感谢穆罕默德·穆扎姆的回复,但我想通过Php进行连接。我正在进行一个基于患者报告的项目,一旦报告通过php准备好,我将单击下载报告,它应该连接到Crystal report并以PDF格式下载$o_craplication->LogOnServer('哪个库','mlims','root','');请在php中尝试此方法,您只有连接问题,并且需要在窗口端进行一些配置才能使crystal reports正常工作。您实际上必须在PHPP中使用JDBC,请先尝试