note 98035 deleted from ref.com by danbrown

From: Date: Fri, 21 May 2010 16:38:46 +0000
Subject: note 98035 deleted from ref.com by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169506@lists.php.net to get a copy of this message
Note Submitter: tob_filt at hotmail dot com ---- This snippet loads a Crystal Report file, assigns the content of the variable 'dateCT' to an empty formula field in the said report and outputs everything in a PDF... took me forever to find how to do it so I figured I'd share. $COM_Object = "CrystalRunTime.Application.10"; $my_report = getcwd() . "\\rapports\\report.rpt"; $my_pdf = getcwd() . "\\rapports\\test.pdf"; $crapp= New COM($COM_Object) or die("Unable to Create Object"); //$test = New COM("CrystalDecisions.CrystalReports.Engine"); try { $creport = $crapp->OpenReport($my_report, 1); $creport->DiscardSavedData; if (!empty($_POST['dateCT'])) { if (!$estPremier) { $formuleSelection .= " AND "; } $formuleSelection .= "("; $formuleSelection .= "{tblcartetempsmain.Date} >= #" . formaterDate($_POST['dateCT']) . "# "; $formuleSelection .= ")"; $estPremier = false; //Don't forget the damn single brackets to wrap the //string!!! $creport->FormulaFields->GetItemByName('txtDateDebut')->Text = "'" . $_POST['dateCT'] . "'"; } $creport->RecordSelectionFormula = $formuleSelection; $creport->ReadRecords(); $creport->ExportOptions->DiskFileName=$my_pdf; $creport->ExportOptions->PDFExportAllPages=true; $creport->ExportOptions->DestinationType=1; // Export to File $creport->ExportOptions->FormatType=31; // Type: PDF $creport->Export(false); header("Location: rapports/test.pdf"); } catch (com_exception $error) { echo $error->getMessage(); }

« previous php.notes (#169506) next »