【发布时间】:2014-08-14 00:37:33
【问题描述】:
我在开始使用 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 objectCrystalRuntime.Application”:第 8 行 C:\wamp\www\classes\report\index.php 中的非注册类
line8: $ObjectFactory= new COM("CrystalReports115.ObjectFactory.1") or die ("Error on load"); // 调用 COM 端口
我已经安装了 CrystalRuntime 11.5 版本 有谁知道我缺少什么模块或者我在 php 中做错了什么?我需要一些图书馆吗? 配置 pnp.ini?配置水晶报表? 我以前从未使用过 COM。
我需要有关连接的帮助(逐步)!
【问题讨论】:
标签: php pdf com crystal-reports