簡體   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