繁体   English   中英

通过 cfml 将 Crystal 报表导出到 java 中的 PDF

[英]Export Crystal reports to PDF in java via cfml

使用 Commandbox 4.7.0+00026,我正在尝试打开 Crystal Reports 文档以准备 output 作为 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 返回的同一文件夹中:

  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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM