PHP and Crystal Reports

PHP and Crystal Reports

am 30.04.2009 03:52:25 von John Messam

--_858eb110-a940-43cc-9912-1c8ab61eb045_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


I am trying to write a php program that opens a number of reports written i=
n Crystal 11. From research on the internet=2C I found that CR would have t=
o be called using COM. So I did that. From the command line it triggers a =
dialog box saying that the version of Crystal the reports was written in wa=
s later than the one that is being used to open it via the php program. T=
he other problem is that when it is run from the browser the program hangs =
on the openReport command

=20

Can anyone assist me on resolving the hanging issue or the entire thing for=
that matter.

=20

Thanks!

=20

John

____________________________________________________________ _____
Show them the way! Add maps and directions to your party invites.=20
http://www.microsoft.com/windows/windowslive/products/events .aspx=

--_858eb110-a940-43cc-9912-1c8ab61eb045_--

Re: PHP and Crystal Reports

am 30.04.2009 10:03:16 von Richard Quadling

2009/4/30 John Messam :
>
> I am trying to write a php program that opens a number of reports written=
in Crystal 11. From research on the internet, I found that CR would have t=
o be called using COM.  So I did that. From the command line it trigge=
rs a dialog box saying that the version of Crystal the reports was written =
in was later than the one that is being used to open it via the php program=
..   The other problem is that when it is run from the browser the prog=
ram hangs on the openReport command
>
>
>
> Can anyone assist me on resolving the hanging issue or the entire thing f=
or that matter.
>
>
>
> Thanks!
>
>
>
> John
>
> ____________________________________________________________ _____
> Show them the way! Add maps and directions to your party invites.
> http://www.microsoft.com/windows/windowslive/products/events .aspx

I use Crystal all day and via PHP also.

Here is the code I use (edited). It might not be perfect, but it works
perfectly.

// Create an Crystal Object Factory.
$o_CrObjectFactory =3D new COM('CrystalReports11.ObjectFactory.1');

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

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

// Load the report.
$o_CrReport =3D $o_CrApplication->OpenReport('C:\Report.rpt', 1); // 1
== crOpenReportByTempCopy.

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

// Don't tell anyone what is going on when running live.
$o_CrReport->DisplayProgressDialog =3D False;

$s_ExportedReport =3D 'C:\Report.pdf';

// Run the report and save the PDF to disk.
$o_CrReport->ExportOptions->DiskFileName =3D $s_ExportedReport;
$o_CrReport->ExportOptions->PDFExportAllPages =3D True;
$o_CrReport->ExportOptions->DestinationType =3D 1; // Export to File
$o_CrReport->ExportOptions->FormatType =3D 31; // 31 =3D PDF, 36 =3D XLS, 1=
4 =3D DOC

// Assign the parameters to the report.
$m_Stuff =3D new Variant();

$o_CrPeriodsParam =3D
$o_CrReport->ParameterFields->GetItemByName('PeriodIDs', $m_Stuff);
$o_CrPeriodsParam->ClearCurrentValueAndRange();

foreach($_SESSION['tabRG_PeriodIDs'] as $i_Period)
{
$o_CrPeriodsParam->AddCurrentValue(intval($i_Period));
}

$o_CrReport->ReadRecords();
$o_CrReport->Export(False);
?>



--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP and Crystal Reports

am 30.04.2009 12:57:04 von Richard Quadling

2009/4/30 John Messam :
> Thank you for responding.  I get the following
> <
> Fatal error: Uncaught exception 'com_exception' with message 'Source:<=
/b>
> Unknown
Description: Unknown' in C:\wamp\www\ledermode\cr4.php=
:15
> Stack trace: #0 C:\wamp\www\ledermode\cr4.php(15):
> com->CreateObject('CrystalRunTime....') #1 {main} thrown in
> C:\wamp\www\ledermode\cr4.php on line 15
>
> Your comments please.
>
>> From: rquadling@googlemail.com
>> Date: Thu, 30 Apr 2009 09:03:16 +0100
>> To: johnmess@hotmail.com
>> CC: php-windows@lists.php.net
>> Subject: Re: [PHP-WIN] PHP and Crystal Reports
>>
>> 2009/4/30 John Messam :
>> >
>> > I am trying to write a php program that opens a number of reports
>> > written in Crystal 11. From research on the internet, I found that CR =
would
>> > have to be called using COM.  So I did that. From the command lin=
e it
>> > triggers a dialog box saying that the version of Crystal the reports w=
as
>> > written in was later than the one that is being used to open it via th=
e php
>> > program.   The other problem is that when it is run from the brow=
ser the
>> > program hangs on the openReport command
>> >
>> >
>> >
>> > Can anyone assist me on resolving the hanging issue or the entire thin=
g
>> > for that matter.
>> >
>> >
>> >
>> > Thanks!
>> >
>> >
>> >
>> > John
>> >
>> > ____________________________________________________________ _____
>> > Show them the way! Add maps and directions to your party invites.
>> > http://www.microsoft.com/windows/windowslive/products/events .aspx
>>
>> I use Crystal all day and via PHP also.
>>
>> Here is the code I use (edited). It might not be perfect, but it works
>> perfectly.
>>
>> >> // Create an Crystal Object Factory.
>> $o_CrObjectFactory =3D new COM('CrystalReports11.ObjectFactory.1');
>>
>> // Create the Crystal Reports Runtime Application.
>> $o_CrApplication =3D
>> $o_CrObjectFactory->CreateObject("CrystalRunTime.Application .11");
>>
>> // Register the typelibrary.
>> com_load_typelib('CrystalDesignRunTime.Application');
>>
>> // Load the report.
>> $o_CrReport =3D $o_CrApplication->OpenReport('C:\Report.rpt', 1); // 1
>> == crOpenReportByTempCopy.
>>
>> // Logon to the database.
>> $o_CrReport->Database->LogOnServer
>> (
>> 'odbc',
>> 'Accounts',
>> registryDatabaseLocations::Database('Accounts'),
>> registryDatabaseLocations::Username('Accounts'),
>> registryDatabaseLocations::Password('Accounts')
>> );
>>
>> // Don't tell anyone what is going on when running live.
>> $o_CrReport->DisplayProgressDialog =3D False;
>>
>> $s_ExportedReport =3D 'C:\Report.pdf';
>>
>> // Run the report and save the PDF to disk.
>> $o_CrReport->ExportOptions->DiskFileName =3D $s_ExportedReport;
>> $o_CrReport->ExportOptions->PDFExportAllPages =3D True;
>> $o_CrReport->ExportOptions->DestinationType =3D 1; // Export to File
>> $o_CrReport->ExportOptions->FormatType =3D 31; // 31 =3D PDF, 36 =3D XLS=
, 14 =3D
>> DOC
>>
>> // Assign the parameters to the report.
>> $m_Stuff =3D new Variant();
>>
>> $o_CrPeriodsParam =3D
>> $o_CrReport->ParameterFields->GetItemByName('PeriodIDs', $m_Stuff);
>> $o_CrPeriodsParam->ClearCurrentValueAndRange();
>>
>> foreach($_SESSION['tabRG_PeriodIDs'] as $i_Period)
>> {
>> $o_CrPeriodsParam->AddCurrentValue(intval($i_Period));
>> }
>>
>> $o_CrReport->ReadRecords();
>> $o_CrReport->Export(False);
>> ?>
>>
>>
>>
>> --
>> -----
>> Richard Quadling
>> Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213=
474731
>> "Standing on the shoulders of some very clever giants!"
>>
>> --
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> ________________________________
> Invite your mail contacts to join your friends list with Windows Live
> Spaces. It's easy! Try it!

Did you edit the code to fit your requirements? I don't know what your
report uses for a database, so you will need to amend the login
details.

Judging by the fact that it was line 15 that went wrong, it looks like
the Crystal Runtime is installed correctly.

Essentially when you run Crystal you need to logon to the data source.
My code uses a registry class to extract the credentials (and I use
ODBC for all of the reports, though to different types of data -
MSSQL, Excel, Sage Retrieve 4GL, etc.)

--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP and Crystal Reports

am 24.08.2009 13:35:31 von sunnylife

You can refer to the design of RAQ Report. For more details you can refer to
http://www.raqsoft.com/.
--
View this message in context: http://www.nabble.com/PHP-and-Crystal-Reports-tp23308716p251 14489.html
Sent from the Php - Windows mailing list archive at Nabble.com.


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP and Crystal Reports

am 24.08.2009 13:46:15 von Richard Quadling

2009/8/24 sunnylife :
>
> You can refer to the design of RAQ Report. For more details you can refer to
> http://www.raqsoft.com/.
> --
> View this message in context: http://www.nabble.com/PHP-and-Crystal-Reports-tp23308716p251 14489.html
> Sent from the Php - Windows mailing list archive at Nabble.com.
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Just in case anyone was wondering, RAQSoft has nothing to do with me,
Richard Alan Quadling!

--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php