2008-10-28 42 views
10

Có ai đó từng sử dụng báo cáo BIRT trong ứng dụng dành cho máy tính để bàn hay không. Tôi đang đến từ môi trường .NET và ở đó bạn có thể sử dụng Crystal Reports để hiển thị các báo cáo trong các ứng dụng máy tính để bàn. Điều này cũng có thể xảy ra với BIRT, mà không phải thiết lập môi trường máy chủ?BIRT trong ứng dụng dành cho máy tính để bàn

Bạn có thể cho tôi một số lời khuyên về cách đạt được mục tiêu này không?

Xin cảm ơn trước.

Trả lời

2

Có, điều đó là có thể. Tôi đã sử dụng nó trong một dự án tôi đã làm khoảng 1-2 năm trước vì vậy tôi sẽ phải liên lạc lại với bạn với các chi tiết. (Mặc dù điều có thể đã thay đổi kể từ đó)

Sau đây là các plugins tôi cần thiết:

<?xml version="1.0" encoding="UTF-8"?> 
<classpath> 
    <classpathentry kind="src" path="src"/> 
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    <classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/> 
    <classpathentry kind="lib" path="lib/log4j-1.2.14.jar"/> 
    <classpathentry kind="lib" path="lib/swt.jar"/> 
    <classpathentry kind="con" path="SWT_CONTAINER"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.chart_2.1.2.v20070205-1728.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.chart.device.extension_2.1.2.v20070205-1728.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.chart.device.swt_2.1.1.v20070205-1728.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.chart.engine_2.1.2.v20070205-1728.jar" sourcepath="C:/Programme/eclipse/plugins/org.eclipse.birt.chart.source_2.2.0.v20070209/src"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.chart.engine.extension_2.1.2.v20070205-1728.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.chart.runtime_2.1.2.v20070205-1728.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.core_2.1.2.v20070205-1728.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.emf.common_2.2.1.v200609210005.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.emf.ecore_2.2.1.v200609210005.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.emf.ecore.xmi_2.2.1.v200609210005.jar"/> 
    <classpathentry kind="lib" path="js.jar"/> 
    <classpathentry kind="lib" path="com.ibm.icu_3.4.5.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.chart.ui_2.1.1.v20070205-1728.jar"/> 
    <classpathentry kind="lib" path="org.eclipse.birt.chart.ui.extension_2.1.2.v20070205-1728.jar"/> 
    <classpathentry kind="lib" path="lib/hsqldb.jar"/> 
    <classpathentry kind="output" path="bin"/> 
</classpath> 
1

Vâng, đó là có thể. Here là một số mô tả chung. Tôi đã sử dụng Birt trong môi trường máy chủ mặc dù như xa như tôi biết có một giao diện RenderContext thông qua đó bạn làm cho các báo cáo của bạn theo cách bạn muốn.

5

Nếu ứng dụng dành cho máy tính để bàn của bạn được viết bằng Nền tảng khách phong phú của Eclipse (RCP), điều này là tầm thường để thêm báo cáo. Tất cả những gì bạn cần làm là thêm plugin org.eclipse.birt.viewer và sau đó sử dụng nó.

Dưới đây là một bài viết giải thích nó: http://digiassn.blogspot.com/2008/08/birt-launch-birt-rcp-application.html

0

Nó có thể và bạn có thể dễ dàng tạo ra một bản xem trước của báo cáo trong một JEditorPane, bạn phải tải về BIRT Runtime và sau đó bạn có thể thử với mã ví dụ đăng trong this đăng trên diễn đàn Eclipse.

0
package com.passport; 

import java.io.FileOutputStream; 
import java.util.Collection; 
import java.util.Iterator; 


import org.eclipse.birt.core.framework.Platform; 
import org.eclipse.birt.report.engine.api.EngineConfig; 
import org.eclipse.birt.report.engine.api.IGetParameterDefinitionTask; 
import org.eclipse.birt.report.engine.api.IParameterDefnBase; 
import org.eclipse.birt.report.engine.api.IRenderOption; 
import org.eclipse.birt.report.engine.api.IReportEngine; 
import org.eclipse.birt.report.engine.api.IReportEngineFactory; 
import org.eclipse.birt.report.engine.api.IReportRunnable; 
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; 
import org.eclipse.birt.report.engine.api.RenderOption; 

public class EngineReport { 
    private static final long serialVersionUID = 1L;  
    private IReportEngine engine=null; 
    private EngineConfig engineconfig = null; 
    private IReportEngineFactory factory = null; 
    private String sourceReport; 
    private String locationReport; 
    private String reportRealPath = ""; 

public static void main(String[] args){ 
    EngineReport engineReport = new EngineReport(); 
    engineReport.save("src/com/passport/report.rptdesign","c:/tmp/rep.doc"); 
} 

private void save(String sourceReport, String locationReport) { 

    this.sourceReport = sourceReport; 
    this.locationReport = locationReport; 
    IReportRunnable design = null; 
    IRenderOption options = null; 
    try { 
     String reportFormat = locationReport.substring(locationReport.lastIndexOf('.')+1); 
     sourceReport = "src/com/passport/report.rptdesign"; 
     if ((sourceReport != null && (sourceReport.length() > 0))) { 

      engineconfig = new EngineConfig(); 
      reportRealPath = ""; 
      Platform.startup(engineconfig); 
      factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);    
      engine = factory.createReportEngine(engineconfig); 
      design = engine.openReportDesign(reportRealPath+sourceReport);   
      IRunAndRenderTask task = engine.createRunAndRenderTask(design);  

      IGetParameterDefinitionTask taskParam = engine.createGetParameterDefinitionTask(design); 
      Collection<?> params = taskParam.getParameterDefns(false); 
      String paramName = null; 
      Iterator<?> iterOuter = params.iterator(); 
      while (iterOuter.hasNext()) { 
       IParameterDefnBase param = (IParameterDefnBase) iterOuter.next(); 
       paramName = param.getName();     
       if (paramName.equalsIgnoreCase("PR_SOME_PARAM")) { 
        task.setParameterValue(paramName,"someparam"); 
       }     
       else if (paramName.equalsIgnoreCase("PR_SOME_PARAM_2")) { 
        task.setParameterValue(paramName,"someparam2"); 
       } 
      }    
      options = new RenderOption();   
      options.setOutputFormat(reportFormat); 

      FileOutputStream fos = new FileOutputStream(locationReport); 
      options.setOutputStream(fos); 
      task.setRenderOption(options); 
      task.run(); 
      task.close(); 
      engine.destroy(); 
      fos.close(); 

     } 
    } catch(Exception e) { 
     System.out.println(e.toString()); 
    } 
} 

}

Các vấn đề liên quan