[英]Export Crystal reports to PDF in java via cfml
Using Commandbox 4.7.0+00026, I'm attempting to open a Crystal Reports document in preparation for output as PDF.使用 Commandbox 4.7.0+00026,我正在尝试打开 Crystal Reports 文档以准备 output 作为 PDF。 I'm not able to get the file to open, getting the error我无法打开文件,出现错误
java.lang.NoClassDefFoundError: com/crystaldecisions/reports/common/data/CrystalResultSet
on line在线的
var rd = rcd.open(reportPath, 0);
I've confirmed CrystalCommon2.jar is in the lib folder.我已经确认 CrystalCommon2.jar 在 lib 文件夹中。
Here's the full CommandBox task runner:这是完整的 CommandBox 任务运行器:
component{
/*
The .jar files from Java Reporting Component SDK are copied to `box\engine\cfml\cli\cfml-web\lib`
*/
property name = "out" inject = "java:java.io.ByteArrayOutputStream";
property name = "crs" inject = "java:com.crystaldecisions.reports.common.data.CrystalResultSet";
property name = "crv" inject = "java:com.crystaldecisions.report.web.viewer.CrystalReportViewer";
property name = "oro" inject = "java:com.crystaldecisions.sdk.occa.report.application.OpenReportOptions";
property name = "rcd" inject = "java:com.crystaldecisions.sdk.occa.report.application.ReportClientDocument";
property name = "ref" inject = "java:com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat";
/* resources
http://www.javathinking.com/2011/09/using-crystal-reports-java-api-to.html
https://stackoverflow.com/questions/3178778/export-crystal-reports-to-pdf-in-java?rq=1
*/
function run(){
var reportPath = "c:\reports\Statement of Account.rpt";
var openAsReadOnly = oro._openAsReadOnly;
var inprocConnectionString = rcd.inprocConnectionString;
var rd = rcd.open(reportPath, 0);
out.reset();
}
}
Some resources indicate a CRConfig.xml needs exist, but I've not had success - tried a myriad of locations.一些资源表明存在 CRConfig.xml 需求,但我没有成功 - 尝试了无数个位置。 CRConfig.xml: CRConfig.xml:
<?xml version="1.0" encoding="utf-8"?>
<CrystalReportEngine-configuration>
<reportlocation>..</reportlocation>
<timeout>0</timeout>
<ExternalFunctionLibraryClassNames>
<classname></classname>
</ExternalFunctionLibraryClassNames>
</CrystalReportEngine-configuration>
Other resources maintain that CrystalReportsEngine-config.xml must exist.其他资源维护 CrystalReportsEngine-config.xml 必须存在。 Again, not sure where it should reside.同样,不确定它应该放在哪里。
<?xml version="1.0" encoding="utf-8"?>
<CrystalReportEngine-configuration>
<reportlocation>c:\reports\</reportlocation>
<timeout>10</timeout>
<keycode>MyLicenseKeyCodeHere</keycode>
</CrystalReportEngine-configuration>
Turns out I was dropping the Crystal Reports jar files in the wrong folder.原来我将 Crystal Reports jar 文件放到了错误的文件夹中。
Drop them into the same folder that's returned by this function:将它们放入此 function 返回的同一文件夹中:
function jarPath(){
variables.jarPath = createObject( "java", "java.io.File" ).init(
createObject( "java", "runwar.LaunchUtil" )
.getClass()
.getProtectionDomain()
.getCodeSource()
.getLocation()
.toURI()
.getSchemeSpecificPart() )
.getAbsolutePath();
job.start(serialize(variables.jarPath));
job.complete();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.