Re: PHP and Crystal Reports
| From: | luhana | Date: | Fri, 23 Dec 2011 01:26:01 +0000 |
| Subject: | Re: PHP and Crystal Reports | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-30755@lists.php.net to get a copy of this message | ||
Dear Sir
I am getting error
Fatal error: Class 'registryDatabaseLocations' not found in
C:\wamp\www\cc3.php on line 19
please guide
Richard Quadling wrote:
>
> 2009/4/30 John Messam <johnmess@hotmail.com>:
>>
>> 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 line it triggers
>> 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
>> program hangs on the openReport command
>>
>>
>>
>> Can anyone assist me on resolving the hanging issue or the entire thing
>> 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.
>
> <?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');
>
> // Load the report.
> $o_CrReport = $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 = False;
>
> $s_ExportedReport = 'C:\Report.pdf';
>
> // Run the report and save the PDF to disk.
> $o_CrReport->ExportOptions->DiskFileName = $s_ExportedReport;
> $o_CrReport->ExportOptions->PDFExportAllPages = True;
> $o_CrReport->ExportOptions->DestinationType = 1; // Export to File
> $o_CrReport->ExportOptions->FormatType = 31; // 31 = PDF, 36 = XLS, 14 =
> DOC
>
> // Assign the parameters to the report.
> $m_Stuff = new Variant();
>
> $o_CrPeriodsParam =
> $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=ZEND002498&r=213474731
> "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
>
>
>
--
View this message in context: http://old.nabble.com/PHP-and-Crystal-Reports-tp23308716p33026407.html
Sent from the Php - Windows mailing list archive at Nabble.com.