我在使用PHP 5开始使用Crystal Reports XI时遇到了问题,但是我无法入门。
这是我使用的一些代码:
//rpt source file
$my_pdf = "d:\\sauve\\report.pdf"; // RPT export to pdf file
//-Create new COM object-depends on your Crystal Report version
$ObjectFactory= new COM("CrystalReports115.ObjectFactory.1") or die ("Error on load"); // call COM port
$crapp = $ObjectFactory-> CreateObject("CrystalRuntime.Application"); // create an instance for Crystal
$creport = $crapp->OpenReport($my_report, 1); // call rpt report
//- Set database logon info - must have
$creport->Database->Tables(1)->SetLogOnInfo ("SUA_DB", "test.mdb", "", "");
//- field prompt or else report will hang - to get through
$creport->EnableParameterPrompting = 0;
//- DiscardSavedData - to refresh then read records
$creport->DiscardSavedData;
$creport->ReadRecords();
//export to PDF process
$creport->ExportOptions->DiskFileName=$my_pdf; //export to pdf
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1; // export to file
$creport->ExportOptions->FormatType=31; // PDF type
$creport->Export(false);
//------ Release the variables ------
$creport = null;
$crapp = null;
$ObjectFactory = null;
//print "<embed src=\"D:\\pop\\EMMEC\\Etats\\RPT-list.pdf\" width=\"100%\" height=\"100%\">"
$file = 'E:/report.pdf';
$filename = 'report.pdf'; /* Note: Always use .pdf at the end. */
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
@readfile($file);
?>
来源链接:http://php.net//manual/kr/class.com.php
我收到一条消息错误:
致命错误:未捕获异常'com_exception',消息'无法创建COM对象CrystalRuntime.Application' in C:\wamp\www\classes\report\index.php on line 8
( ! ) com_exception: Failed to create COM object
CrystalRuntime.Application':Classenonenregistrée位于第8行的C:\ wamp \ www \ classes \ report \ index.php
line8:$ ObjectFactory = new COM(“CrystalReports115.ObjectFactory.1”)或die(“加载时出错”); //调用COM端口
我已经安装了CrystalRuntime 11.5版本 有人知道我错过了什么模块,或者我在php中做错了什么?我需要一些图书馆吗? 配置pnp.ini?配置Crystal报表? 我以前从未与COM合作过。
我需要有关连接的帮助(一步一步)!
答案 0 :(得分:0)
您需要在 php.ini 中添加以下行:
[COM_DOT_NET]
extension=php_com_dotnet.dll