Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP and Crystal Report 8.5

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

PHP and Crystal Report 8.5

Postby kirkb » Sat Feb 11, 2012 3:15 am

I am a new at PHP and I am trying to get PHP and Crystal 8.5 to cooperate but it works sometimes about three to four times and then I keep getting the ambiguous 'Server not yet opened' error message.

I have been Googling for days without much success.

My code is below can anyone point me in the right direction please. I am using PHP 5.

<?php

$cr_report = "C:\\wamp\\www\\site\\Report1.rpt";
$exp_pdf = "C:\\wamp\\www\\site\\test1.pdf";

$ObjectFactory= New COM("CrystalRuntime.Application.8.5");
$creport = $ObjectFactory->OpenReport($cr_report, 1);

$creport->ExportOptions->DiskFileName=$exp_pdf;
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1;
$creport->ExportOptions->FormatType=31;
$creport->Export(false);

$len = filesize($exp_pdf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=$exp_pdf");
readfile($exp_pdf);

?>
kirkb
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sat Feb 04, 2012 2:32 pm

Re: PHP and Crystal Report 8.5

Postby kirkb » Sat Feb 11, 2012 5:42 pm

Ok, so I upgraded from Crystal 8.5 to Crystal 11. What happens now is this, the Crystal report is only displayed in the browser when it is saved with data.

Whenever I try to pass parameters to refresh the report to it hangs. Any ideas as to how to jump this hurdle anyone?

The code I am using is below:
<?php

$cr_report = "C://wamp//www//site//report3.rpt";
$export_pdf = "C://wamp//www//site//reportin.pdf";

$ObjectFactory= New COM("CrystalReports11.ObjectFactory.1");
$crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");
$creport = $crapp->OpenReport($cr_report, 1);

$creport->EnableParameterPrompting = 0;
$creport->DiscardSavedData;

$creport->ReadRecords();
$zz= $creport->ParameterFields(1)->SetCurrentValue("ANDREAG");

$creport->ExportOptions->DiskFileName=$export_pdf;
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1;
$creport->ExportOptions->FormatType=31;
$creport->Export(false);

$file_len = filesize($export_pdf);
header("Content-type: application/pdf");
header("Content-Length: $file_len");
header("Content-Disposition: inline; filename=$export_pdf");
readfile($export_pdf);

//------ Release the variables
$creport = null;
$crapp = null;
$ObjectFactory = null;
?>
kirkb
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sat Feb 04, 2012 2:32 pm

Re: PHP and Crystal Report 8.5

Postby kirkb » Sat Feb 11, 2012 6:09 pm

got it!
kirkb
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sat Feb 04, 2012 2:32 pm

Re: PHP and Crystal Report 8.5

Postby adnyana112 » Fri Oct 12, 2012 9:05 am

How the solution, if you dont mind, can you tell how got it? cause now i confuse to connect php to crystal report....

thx
adnyana112
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Oct 12, 2012 9:01 am

Re: PHP and Crystal Report 8.5

Postby seandisanti » Fri Oct 12, 2012 9:11 am

lol, good job figuring it out on your own, but please post your findings so the thread may be of use to others with the same challenge.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: PHP and Crystal Report 8.5

Postby monty » Thu Dec 06, 2012 3:21 am

My name is Monty and i am newbie to php just would like to know how to call crystal report passing query from php.I have used reportobject->SQLQuery($query) but getting error Unable to lookup SQLQuery.Is there any other wat to pass query to crystal report using php.
monty
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Dec 06, 2012 3:09 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.