2016-02-01 80 views
8

我正在尝试使用php脚本生成水晶报告。脚本似乎在ReadRecords()后面挂起;日志文件中没有生成错误消息。我做错了什么?通过PHP生成水晶报告挂起

$my_report = "C:\\inetpub\\wwwroot\\mamobile\\reports\\invoice.rpt"; 
$my_pdf = "C:\\inetpub\\wwwroot\\mamobile\\reports\\test.pdf"; 

$ObjectFactory = new COM("CrystalReports115.ObjectFactory.1"); 

$crapp = $ObjectFactory->CreateObject("CrystalDesignRuntime.Application.11"); 

$creport = $crapp->OpenReport($my_report, 1); 

$creport->EnableParameterPrompting = 0; 

$creport->DiscardSavedData; 
$creport->ReadRecords(); 

$creport->FormulaSyntax = 0; 
$creport->RecordSelectionFormula = "{invoice.invoiceid} = 20070128114815"; 

$creport->ExportOptions->DiskFileName = $my_pdf; 
$creport->ExportOptions->FormatType = 31; 
$creport->ExportOptions->DestinationType=1; 
$creport->Export(false); 

$creport = null; 
$crapp = null; 
$ObjectFactory = null; 

此代码的类似版本适用于不同的报告。

​​

回答

3

这是固定我的问题。

$my_report = "C:\\inetpub\\wwwroot\\mamobile\\reports\\invoice.rpt"; 
$my_pdf = "C:\\inetpub\\wwwroot\\mamobile\\reports\\test.pdf"; 

$ObjectFactory = new COM("CrystalReports115.ObjectFactory.1"); 

$crapp = $ObjectFactory->CreateObject("CrystalRuntime.Application.11"); 

$creport = $crapp->OpenReport($my_report, 1); 

$creport->EnableParameterPrompting = 0; 
$creport->FormulaSyntax = 0; 


$creport->DiscardSavedData(); 
$creport->RecordSelectionFormula = "{invoice.invoiceid} = 20070128114815"; 
$creport->ReadRecords(); 

$creport->ExportOptions->DiskFileName = $my_pdf; 
$creport->ExportOptions->FormatType = 31; 
$creport->ExportOptions->DestinationType=1; 
$creport->Export(false); 

$creport = null; 
$crapp = null; 
$ObjectFactory = null; 
+0

谢谢你。你被同样的问题刺痛了 - CrystalRuntime,而不是CrystalDesignRuntime – Patrick

1
  1. DIRECTORY_SEPARATOR代替\\

  2. 要调用$creport->DiscardSavedData你应该使用 - 如果这是一个变量,它什么都不做。如果它是一个函数调用,它应该是$creport->DiscardSavedData()

  3. 在脚本开始尝试这些设置:

    ini_set('error_reporting', -1); # displays all errors 
    ini_set('display_errors', 1); # reports errors to browser/console 
    
+0

感谢您的帮助!我设法弄清楚了。但我也会玩这些设置:) – Hackmodford