?
Solved

PHP / Crystal Reports 12

Posted on 2010-01-11
4
Medium Priority
?
3,160 Views
Last Modified: 2013-12-12
I am attempting to use a script I found to work with my application and some reports I have created in Crystal Reports 12.

  I get the following error when trying to load.

Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `CrystalRuntime.Application12': Invalid syntax ' in C:\xampp\htdocs\salesroomtools\crystal.php:2 Stack trace: #0 C:\xampp\htdocs\salesroomtools\crystal.php(2): com->com('CrystalRuntime....') #1 {main} thrown in C:\xampp\htdocs\salesroomtools\crystal.php on line 2


Any Ideas?!  I can create new com objects with other applications without error...
<?php

$crapp = new com("CrystalRuntime.Application.12") or die ("Error on load");
$creport = $crapp->OpenReport("c:/test.rpt", 1);
$creport->ExportOptions->DiskFileName="c:/test.rtf";
$creport->ExportOptions->DestinationType=1; // Export to File
$creport->ExportOptions->FormatType=4; // Type: RTF
$creport->DiscardSavedData();
$creport->Export(false);

$creport = null;
$crapp = null;

print "...done";

?>

Open in new window

0
Comment
Question by:charlesparks
  • 2
2 Comments
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 2000 total points
ID: 26291318
Simply put, you do not have the Crystal Reports RunTime installed.

If you've only installed the user level Crystal Reports (Standard or Professional), then you won't have this component.

You need the Developer Edition.

The DevEd contains re-distributable components normally used for integration into third party applications.

Or, you are calling it wrong.

Get hold of a TypeLib tool. I use TypeLib Browser V4.0.13 by José Roca (freeware).

http://www.jose.it-berater.org/
http://www.jose.it-berater.org/smfforum/index.php?topic=3090.0 (login required).
http://www.jose.it-berater.org/webpages_images/TLB_400.png

This will allow you to investigate exactly what components you have installed (remember that the web server will need these if you wish to do this on a separate machine).

I use CRXI.

I have Crystal Reports ActiveX Designer Design and Runtime Library 11.0.

I've included a screen snapshot of the Dual Interfaces for the IApplication element.

My edited code for using this is (lot's of code removed - just showing the sequence of calls I make) ...

<?php
// Create an Crystal Object Factory.
$o_CrObjectFactory = New COM('CrystalReports11.ObjectFactory.1');

// Create the Crystal Reports Runtime Application.
$o_CrApplication = $o_CrObjectFactory->CreateObject("CrystalRunTime.Application.11");

// Register the typelibrary.
com_load_typelib('CrystalDesignRunTime.Application');


//
$s_RptFilename = realpath("../CrystalReports/{$s_ReportType} Bank Report.rpt");

// Load the report.
$o_CrReport = $o_CrApplication->OpenReport($s_RptFilename, 1); // 1 == crOpenReportByTempCopy.

// Logon to the database.
$o_CrReport->Database->LogOnServer
      (
      'odbc',
      'CCC',
      registryDatabaseLocations_V2::Database(registryDatabaseLocations_V2::REG_CONN_CCCSQL),
      registryDatabaseLocations_V2::Username(registryDatabaseLocations_V2::REG_CONN_CCCSQL),
      registryDatabaseLocations_V2::Password(registryDatabaseLocations_V2::REG_CONN_CCCSQL)
      );

// Iterate the parameters and set them to the required values shown above.
foreach($o_CrReport->ParameterFields as $i_Parameter => $o_Parameter)
      {
      $o_Parameter->SetCurrentValue($a_ParametersToSupply[$o_Parameter->Name], $o_Parameter->ValueType);
      }

// Run the report and save the PDF to disk.
$o_CrReport->ReadRecords();
$o_CrReport->ExportOptions->DiskFileName = $s_PDF;
$o_CrReport->ExportOptions->PDFExportAllPages = True;
$o_CrReport->ExportOptions->DestinationType = 1; // Export to File
$o_CrReport->ExportOptions->FormatType = 31; // Type: PDF
$o_CrReport->Export(False);

?>


NOTE: Lot's of code removed.
TypeLib.png
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 26540671
The example code I supplied works fine for Crystal Reports XI. It was based upon details gathered from the COM library by the use of the TypeLib browser tool.

Without feedback, I don't know if the code will work on CR 12 without modification.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question