本文介绍了使用PHP以pdf格式导出时,为什么crystal report不会生成数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我试试这段代码。 它有效,但无法以pdf格式导出水晶报表数据。如何使用水晶报告数据导出它?谢谢 我尝试过: <?php b $ b $ my_pdf =C:\ xampp\htdocs \CrystalReport1.pdf; $ databaselocation =C:\ Users \ Plastimer \Documents\Visual Studio 2015 \Projects\CReport\CReport \TABLEREPORT.mdb; $ conn =新COM('ADODB.Connection')或退出('无法启动ADO。'); $ conn-> Open(Provider = Microsoft.Jet.OLEDB.4.0; Data Source = $ databaselocation); $ sql ='SELECT`STOCK_ISSUANCE_HDR` .SIS#`,`STOCK_ISSUANCE_HDR` .SIS DATE`,`STOCK_ISSUANCE_HDR``TRANS#* A`,`T_STOCKFG`。PRODCODE * B`,`T_STOCKFG``STK_DESC `,`STOCK_ISSUANCE_DTL``QTY`,`STOCK_ISSUANCE_DTL``REMARKS` FROM(`STOCK_ISSUANCE_HDR``STOCK_ISSUANCE_HDR` INNER JOIN`STOCK_ISSUANCE_DTL``STOCK_ISSUANCE_DTL`'STOCK_ISSUANCE_HDR``TRANS#* A` =`STOCK_ISSUANCE_DTL``TRANS#* A`)INNER JOIN`T_STOCKFG``T_STOCKFG` ON`STOCK_ISSUANCE_DTL``PRODCODE * B` =`T_STOCKFG`.PRODCODE * B` '; $ rs = $ conn->执行($ sql); $ my_report =C:\ Users \Plastimer \Documents\CrystalReport1.rpt; $ ObjectFactory = new COM(CrystalReports13.ObjectFactory.1)或die(加载时出错); $ crapp = $ ObjectFactory->的CreateObject( CrystalDesignRunTime.Application); $ creport = $ crapp-> OpenReport($ my_report,1); $ rptParams = $ creport-> ParameterFields; $ rptParam = $ rptParams-> Item(1); $ para = $ creport-> ParameterFields; $ param = $ para-> Item(2); $ oScript = new COM(MSScriptControl.ScriptControl); $ oScript-> Language =VBScript; $ oScript-> AllowUI = false; $ oScript-> AddObject('rptParam',$ rptParam,false); $ oScript-> AddCode('函数SetDateParameter(end_date) rptParam.AddCurrentValue(CDate(end_date)) 结束函数'); $ oScript = new COM(MSScriptControl.ScriptControl); $ oScript-> Language =VBScript; $ oScript-> AllowUI = false; $ oScript-> AddObject('param',$ param,false); $ oScript-> AddCode('Function SetDateParameter(srat_date) param.AddCurrentValue(CDate(srat_date)) 结束函数'); $ creport-> DiscardSavedData(); $ creport-> ReadRecords(); $ creport-> EnableParameterPrompting = 0; $ creport-> FormulaSyntax = 0; $ creport-> ExportOptions-> DiskFileName = $ my_pdf; $ creport-> ExportOptions-> PDFExportAllPages = True; $ creport-> ExportOptions-> DestinationType = 1; $ creport-> ExportOptions-> FormatType = 31; $ creport->导出(true); print< embed src ='http:// localhost / CrystalReport1。 pdf'width = \100%\height = \100%\> ?> I try this code.It works but can't export crystal report data in pdf. How can I export it with crystal report data? ThanksWhat I have tried:<?php $my_pdf = "C:\xampp\htdocs\CrystalReport1.pdf";$databaselocation = "C:\Users\Plastimer\Documents\Visual Studio 2015\Projects\CReport\CReport\TABLEREPORT.mdb"; $conn = new COM('ADODB.Connection') or exit('Cannot start ADO.'); $conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$databaselocation");$sql = 'SELECT `STOCK_ISSUANCE_HDR`.`SIS #`, `STOCK_ISSUANCE_HDR`.`SIS DATE`, `STOCK_ISSUANCE_HDR`.`TRANS #*A`, `T_STOCKFG`.`PRODCODE *B`, `T_STOCKFG`.`STK_DESC`, `STOCK_ISSUANCE_DTL`.`QTY`, `STOCK_ISSUANCE_DTL`.`REMARKS` FROM (`STOCK_ISSUANCE_HDR` `STOCK_ISSUANCE_HDR` INNER JOIN `STOCK_ISSUANCE_DTL` `STOCK_ISSUANCE_DTL` ON `STOCK_ISSUANCE_HDR`.`TRANS #*A`=`STOCK_ISSUANCE_DTL`.`TRANS #*A`) INNER JOIN `T_STOCKFG` `T_STOCKFG` ON `STOCK_ISSUANCE_DTL`.`PRODCODE *B`=`T_STOCKFG`.`PRODCODE *B`';$rs = $conn->Execute($sql); $my_report = "C:\Users\Plastimer\Documents\CrystalReport1.rpt"; $ObjectFactory= new COM("CrystalReports13.ObjectFactory.1") or die ("Error on load"); $crapp = $ObjectFactory-> CreateObject("CrystalDesignRunTime.Application"); $creport = $crapp->OpenReport($my_report, 1); $rptParams = $creport->ParameterFields;$rptParam = $rptParams->Item(1);$para = $creport->ParameterFields;$param = $para->Item(2);$oScript = new COM("MSScriptControl.ScriptControl");$oScript->Language = "VBScript";$oScript->AllowUI = false;$oScript->AddObject('rptParam', $rptParam, false);$oScript->AddCode('Function SetDateParameter(end_date)rptParam.AddCurrentValue(CDate(end_date))End Function');$oScript = new COM("MSScriptControl.ScriptControl");$oScript->Language = "VBScript";$oScript->AllowUI = false;$oScript->AddObject('param', $param,false);$oScript->AddCode('Function SetDateParameter(srat_date)param.AddCurrentValue(CDate(srat_date))End Function');$creport->DiscardSavedData(); $creport->ReadRecords(); $creport->EnableParameterPrompting = 0; $creport->FormulaSyntax = 0;$creport->ExportOptions->DiskFileName = $my_pdf;$creport->ExportOptions->PDFExportAllPages = True;$creport->ExportOptions->DestinationType = 1; $creport->ExportOptions->FormatType = 31; $creport->Export(true);print "<embed src='http://localhost/CrystalReport1.pdf' width=\"100%\" height=\"100%\">"?>推荐答案 my_pdf =C:\ xampp \ htdocs \CrystalReport1.pdf; my_pdf = "C:\xampp\htdocs\CrystalReport1.pdf"; databaselocation =C:\ Users \ Plastimer \Documents \ Visis Studio 2015 \Projects\CReport\CReport\TABLEREPORT.mdb; databaselocation = "C:\Users\Plastimer\Documents\Visual Studio 2015\Projects\CReport\CReport\TABLEREPORT.mdb"; conn = new COM('ADODB.Connection')或退出('无法启动ADO。'); conn = new COM('ADODB.Connection') or exit('Cannot start ADO.'); 这篇关于使用PHP以pdf格式导出时,为什么crystal report不会生成数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-15 19:23