gpt4 book ai didi

java - 在java中通过cfml将 Crystal 报表导出为PDF

转载 作者:行者123 更新时间:2023-12-01 23:38:25 33 4
gpt4 key购买 nike

使用 Commandbox 4.7.0+00026,我尝试打开 Crystal Reports 文档,准备输出为 PDF。我无法打开文件,出现错误

java.lang.NoClassDefFoundError:com/crystaldecisions/reports/common/data/CrystalResultSet

上线

var rd = rcd.open(reportPath, 0);

我已确认 CrystalCommon2.jar 位于 lib 文件夹中。

这是完整的 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();

}
}

一些资源表明需要存在 CRConfig.xml,但我没有成功 - 尝试了无数位置。CRConfig.xml:

<?xml version="1.0" encoding="utf-8"?>
<CrystalReportEngine-configuration>
<reportlocation>..</reportlocation>
<timeout>0</timeout>
<ExternalFunctionLibraryClassNames>
<classname></classname>
</ExternalFunctionLibraryClassNames>
</CrystalReportEngine-configuration>

其他资源认为 CrystalReportsEngine-config.xml 必须存在。同样,不确定它应该驻留在哪里。

<?xml version="1.0" encoding="utf-8"?>  
<CrystalReportEngine-configuration>
<reportlocation>c:\reports\</reportlocation>
<timeout>10</timeout>
<keycode>MyLicenseKeyCodeHere</keycode>
</CrystalReportEngine-configuration>

最佳答案

原来我将 Crystal Reports jar 文件放入了错误的文件夹中。

将它们放入此函数返回的同一文件夹中:

  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();

}

关于java - 在java中通过cfml将 Crystal 报表导出为PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58270969/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com