Problème avec la methode createObject pour crystal reports

Résolu
reddev26 Messages postés 10 Date d'inscription mardi 3 avril 2007 Statut Membre Dernière intervention 22 juin 2010 - 21 juin 2010 à 15:29
 atifodev - 5 mars 2013 à 11:32
je souhaite générer un rapport avec crystal reports 9 à partir de mon application PHP, mais je reçois l'erreur suivante:

Fatal error: Call to undefined method com::CreateObject() in C:\Program Files\EasyPHP 3\www\checkListISO9001\v3\checkList\resultat.php on line 75

Voici mon code:

<?php

//- Variables - for your RPT and PDF
$my_report = "C:\\Program Files\\EasyPHP 3\\www\\checkListISO9001\\v3\\checkList\\rapportISO.rpt"; //rpt source file
$my_pdf = "C:\\Program Files\\EasyPHP 3\\www\\checkListISO9001\\v3\\checkList\\rapportISO.pdf"; // RPT export to pdf file
//-Create new COM object-depends on your Crystal Report version
$ObjectFactory= new COM("CrystalRuntime.Application.9") or die ("Error on load"); // call COM port
$crapp = $ObjectFactory-> CreateObject("CrystalDesignRunTime.Application"); // create an instance for Crystal
$creport = $crapp->OpenReport($my_report, 1); // call rpt report

// to refresh data before

//- Set database logon info - must have
$creport->Database->Tables(1)->SetLogOnInfo("localhost", "test", "root", "admin");

//- field prompt or else report will hang - to get through
$creport->EnableParameterPrompting = 0;

//- DiscardSavedData - to refresh then read records
$creport->DiscardSavedData;
$creport->ReadRecords();

//------ Pass formula fields --------
$creport->FormulaFields->Item(1)->Text = ("'My Report Title'");
$creport->ParameterFields(1)->AddCurrentValue ("FirstParameter");
$creport->ParameterFields(2)->AddCurrentValue (2000);

//export to PDF process
$creport->ExportOptions->DiskFileName=$my_pdf; //export to pdf
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1; // export to file
$creport->ExportOptions->FormatType=31; // PDF type
$creport->Export(false);

//------ Release the variables ------
$creport = null;
$crapp = null;
$ObjectFactory = null;

?>

N.B: j'utilise EasyPHP 2.0

Votre aide sera beaucoup appréciée les amis.

4 réponses

reddev26 Messages postés 10 Date d'inscription mardi 3 avril 2007 Statut Membre Dernière intervention 22 juin 2010
22 juin 2010 à 10:32
J'ai réglé le problème, en effet je n'avais même pas besoin d'appeler la méthode createObject ($crapp = $ObjectFactory-> CreateObject("CrystalDesignRunTime.Application")). Par conséquent, il faut éliminer la variable $crapp.
3
leseul2007 Messages postés 9 Date d'inscription lundi 26 février 2007 Statut Membre Dernière intervention 16 avril 2012
13 avril 2012 à 17:33
Slt tu peux Poster ta réponse s'il te plait

Ibrahim
0
leseul2007 Messages postés 9 Date d'inscription lundi 26 février 2007 Statut Membre Dernière intervention 16 avril 2012
16 avril 2012 à 14:40
Salut à tous,
Lorsque j'utilise le script pour afficher mon état, l'état n'est pas rafraîchit. Et lorsque j'utilise les lignes suivantes

//- DiscardSavedData - to refresh then read records
$creport->DiscardSavedData;
$creport->ReadRecords();

mon application se plante

Ibrahim
0
Voici mon code pour ouvrir une etat crystal report 11 avec php base mysql
toujours j ai un probleme Call to undefined method com::OpenReport()
merci de suivie


<?php

$app_obj = new COM("CrystalReports11.ObjectFactory.1") or Die ("Did not open");
$etat="D:\rpt.rpt"; // donner le chemain du rapport
$rpt_obj=$app_obj->OpenReport($etat);


$rpt_obj->RecordSelectionFormula "{candidat_c.numero_cin_c} '07102715' " ;

$rpt_obj->ExportOptions->DiskFileName="D:\chier.pdf"; // chemain ou mettre le fichier pdf
$rpt_obj->ExportOptions->PDFExportAllPages=true;
$rpt_obj->ExportOptions->DestinationType=1; // Export to File
$rpt_obj->ExportOptions->FormatType=31; // Type: PDF
$rpt_obj->Export(false);
$my_pdf="D:\chier.pdf";



header('Content-type: application/pdf');
header('Content-Length: $len');
//header('Content-Disposition: inline; filename="'.$my_pdf.'"');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Pragma: anytextexeptno-cache', true);
header('Cache-control: private');
header('Expires: 0');
header('Content-Disposition: inline; filename="'.$my_pdf.'"');

readfile($my_pdf);

?>
0
Rejoignez-nous