1 Replies - 4806 Views - Last Post: 16 November 2015 - 10:25 AM Rate Topic: -----

#1 R. Gregorio   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 09-November 15

Calling Crystal Report in php using COM function

Posted 15 November 2015 - 07:12 PM


I have this code :helpsmilie:

<?php 
//------  Variables ------ 
$my_report = "crystal/COMSYS P013 PRODUCTION PERFORMANCE SUMMARY bak20151012.rpt"; 
$my_pdf = "pdf/test.pdf"; 

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

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

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

//------ Connect to DB2 DataBase ------ 
$crapp->LogOnServer('localhost', 'root', 'qwertyuiop1234', 'comsys'); 

//------ Put the values that you want -------- 
$creport->RecordSelectionFormula="{test.no}='ANY_VALUE'"; 

//------ This is very important. DiscardSavedData make a 
// Refresh in your data ------- 
$creport->DiscardSavedData; 

//------ Read the records :-P ------- 
$creport->ReadRecords(); 

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




With i want to use to call crystal report in php using a COM function.
I already done the steps online to activate the COM Function on my php.ini and add the .dll on my php folder and windows/system32.

So here's my poblem :wacko:
(a)It keeps on giving me this error "Fatal error: Class 'COM' not found in C:\xampp\htdocs\project\sample_crystal.php on line 7" so I guess my error is this part?
//------ Create a new COM Object of Crytal Reports XI ------
  $ObjectFactory= new COM("CrystalReports11.ObjectFactory.1");  

(B) and how to know what my crystal report version number is? Its Crystal Report 2013.

Thank you in advance for the answers! :smile2:
I Hope someone can help me out or give me advice. :sweatdrop:


Is This A Good Question/Topic? 0
  • +

Replies To: Calling Crystal Report in php using COM function

#2 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2145
  • View blog
  • Posts: 6,520
  • Joined: 15-January 14

Re: Calling Crystal Report in php using COM function

Posted 16 November 2015 - 10:25 AM

You have to enable the COM extension in php.ini and then restart the server:

http://stackoverflow...s-com-not-found
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1