Как передать параметры в отчет Crystal в php?

Я сгенерировал отчет о кристалле с помощью php COM. Теперь мне нужно передать некоторые параметры в отчет без запроса. Ниже приведен код:

<?php

//------  Variables ------
$my_report = "C:\\Apache2\htdocs\\test\\MyReport.rpt";  //This must be the full path to the file
$my_pdf = "C:\\Apache2\htdocs\\test\\MyReport.pdf";

//------ Create a new COM Object of Crytal Reports 10 ------
$ObjectFactory= new COM("CrystalReports10.ObjectFactory.1");

//------ Create a instance of library Application -------
$crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application.10");

//------ Open your rpt file ------
$creport = $crapp->OpenReport($my_report, 1);

//------ Set database logon info ------
$creport->Database->Tables(1)->SetLogOnInfo("MYSERVER", "Database", "user", "password");

//------ Suppress the Parameter field prompt or else report will hang ------
$creport->EnableParameterPrompting = 0;

//------ DiscardSavedData make a Refresh in your data -------
$creport->DiscardSavedData;
$creport->ReadRecords();

//------ Pass formula fields --------
// $creport->FormulaFields->Item(1)->Text = ("'My Report Title'");
$creport->ParameterFields(1)->AddCurrentValue ("Hello World");   // <-- param 1
$creport->ParameterFields(2)->AddCurrentValue (123); // <-- param 2

//------ 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;

//------ Embed the report in the webpage ------
print "<embed src=\"MyReport.pdf\" width=\"100%\" height=\"100%\">"
?>

В CR в Field Explorer я щелкаю правой кнопкой мыши на полях параметров и выбираю New. Тем не менее, я не знаю, что такое имя поля параметров для назначения и другие настройки, чтобы получить значения param1 и param2 в приведенном выше коде.

Помощь приветствуется.

0

Решение

$ creport-> ParameterFields (1) -> SetCurrentValue («Hello World»); // <- параграф 1

$ creport-> ParameterFields (2) -> SetCurrentValue (123); // <- параграф 2

Надеюсь, это поможет вам.

0

Другие решения

Других решений пока нет …