?
Solved

PHP / Crystal Reports 12

Posted on 2010-01-11
4
Medium Priority
?
2,988 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 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