note 79781 modified in ref.com by danbrown

From: Date: Mon, 21 Dec 2009 17:02:34 +0000
Subject: note 79781 modified in ref.com by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164193@lists.php.net to get a copy of this message
Guys, I found a way to pass parameters from PHP to Crystal Reports 11 without hanging!!!! So the problem is the prompt for params dialog: <?php $ObjectFactory= New COM("CrystalReports11.ObjectFactory.1"); $crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application"); $creport = $crapp->OpenReport($my_report, 1); $creport->Database->Tables-> Item(1)->ConnectionProperties['User ID'] = 'blablabla'; $creport->Database->Tables-> Item(1)->ConnectionProperties['Password'] = 'blablabla'; $creport->FormulaSyntax = 0; $creport->RecordSelectionFormula= "{TABLENAME.FIELDNAME}='$USRID'"; //This is it, this avoids the hanging! $creport->EnableParameterPrompting = 0; $creport->DiscardSavedData; $creport->ReadRecords(); //it is essential to assign the param values here after the readrecords otherwise you will not pass anything... $zz= $creport->ParameterFields(1)->SetCurrentValue(500); $creport->ExportOptions->DiskFileName=$exp_pdf; $creport->ExportOptions->PDFExportAllPages=true; $creport->ExportOptions->DestinationType=1; $creport->ExportOptions->FormatType=31; $creport->Export(false); $creport->ExportOptions->DiskFileName=$exp_xls; $creport->ExportOptions->PDFExportAllPages=true; $creport->ExportOptions->DestinationType=1; $creport->ExportOptions->FormatType=29; $creport->Export(false); $len = filesize($exp_pdf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=reportin.pdf"); readfile("reportin.pdf"); //------ Release the variables $creport = null; $crapp = null; $ObjectFactory = null; ?> Have fun, Andras --was-- Guys, I found a way to pass parameters from PHP to Crystal Reports 11 without hanging!!!! So the problem is the prompt for params dialog: $ObjectFactory= New COM("CrystalReports11.ObjectFactory.1"); $crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application"); $creport = $crapp->OpenReport($my_report, 1); $creport->Database->Tables-> Item(1)->ConnectionProperties['User ID'] = 'blablabla'; $creport->Database->Tables-> Item(1)->ConnectionProperties['Password'] = 'blablabla'; $creport->FormulaSyntax = 0; $creport->RecordSelectionFormula= "{TABLENAME.FIELDNAME}='$USRID'"; //This is it, this avoids the hanging! $creport->EnableParameterPrompting = 0; $creport->DiscardSavedData; $creport->ReadRecords(); //it is essential to assign the param values here after the readrecords otherwise you will not pass anything... $zz= $creport->ParameterFields(1)->SetCurrentValue(500); $creport->ExportOptions->DiskFileName=$exp_pdf; $creport->ExportOptions->PDFExportAllPages=true; $creport->ExportOptions->DestinationType=1; $creport->ExportOptions->FormatType=31; $creport->Export(false); $creport->ExportOptions->DiskFileName=$exp_xls; $creport->ExportOptions->PDFExportAllPages=true; $creport->ExportOptions->DestinationType=1; $creport->ExportOptions->FormatType=29; $creport->Export(false); $len = filesize($exp_pdf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=reportin.pdf"); readfile("reportin.pdf"); //------ Release the variables $creport = null; $crapp = null; $ObjectFactory = null; Have fun, Andras http://php.net/manual/en/ref.com.php

« previous php.notes (#164193) next »