Advertisement
julong

Crystal Report

Feb 26th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2.  
  3. //- Variables - for your RPT and PDF
  4. //echo "Print Report Test";
  5. $my_report = "D:\\Program Fiels\\xampp\\htdocs\\RPT\\RPT-list.rpt"; //
  6. //rpt source file
  7. $my_pdf = "D:\\Program Fiels\\xampp\\htdocs\\RPT\\RPT-list.pdf"; // RPT export to pdf file
  8. //-Create new COM object-depends on your Crystal Report version
  9. $ObjectFactory= new COM("CrystalReports10.ObjectFactory.1") or die ("Error on load"); // call COM port
  10. $crapp = $ObjectFactory-> CreateObject("CrystalRuntime.Application.10"); // create an instance for Crystal
  11. $creport = $crapp->OpenReport($my_report, 1); // call rpt report
  12.  
  13. // to refresh data before
  14.  
  15. //- Set database logon info - must have
  16. $creport->Database->Tables(1)->SetLogOnInfo("servername", "username", "password", "databasename");
  17. //- field prompt or else report will hang - to get through
  18. $creport->EnableParameterPrompting = 0;
  19.  
  20. //- DiscardSavedData - to refresh then read records
  21. $creport->DiscardSavedData;
  22. $creport->ReadRecords();
  23.  
  24.  
  25. //export to PDF process
  26. $creport->ExportOptions->DiskFileName=$my_pdf; //export to pdf
  27. $creport->ExportOptions->PDFExportAllPages=true;
  28. $creport->ExportOptions->DestinationType=1; // export to file
  29. $creport->ExportOptions->FormatType=31; // PDF type
  30. $creport->Export(false);
  31.  
  32. //------ Release the variables ------
  33. $creport = null;
  34. $crapp = null;
  35. $ObjectFactory = null;
  36.  
  37.  
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement