Khi tôi hiểu bạn, bạn đang cố gắng tạo một biểu mẫu báo cáo birt một servlet nơi bạn có * .rptdesign ở một nơi nào đó.
Tốt, nhìn vào đoạn mã sau
this.bundle = ResourceBundle.getBundle("com.tts.mersal.resources.MersalResources");
this.config = new EngineConfig();
this.config.setEngineHome(bundle.getString("BIRT_ENGINE_HOME"));
this.config.setLogConfig(bundle.getString("BIRT_LOGGING_FOLDER_PATH"), Level.ALL);
Platform.startup(config);
this.factory = (IReportEngineFactory)Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
this.engine = factory.createReportEngine(config);
this.engine.changeLogLevel(Level.ALL);
ContentReader contentReader = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getFileFolderService().getReader(MersalOutboundReportDialogBean.this.dialogReportNode.getNodeRef());
IReportRunnable report = MersalOutboundReportDialogBean.this.getEngine().openReportDesign(contentReader.getContentInputStream());
ReportDesignHandle designHandle = (ReportDesignHandle)report.getDesignHandle();
OdaDataSource source = (OdaDataSource)designHandle.getModule().findDataSource(DATA_SOURCE_NAME);
source.setProperty(source.getPropertyDefn("FILELIST"), buildUrl((String)source.getProperty(designHandle.getModule(), "FILELIST")));
IRunAndRenderTask runAndRenderTask = MersalOutboundReportDialogBean.this.getEngine().createRunAndRenderTask(report);
HTMLRenderOption render = new HTMLRenderOption();
render.setOutputFileName("G:/Render.html");
render.setOutputFormat("html");
runAndRenderTask.setRenderOption(render);
runAndRenderTask.run();
runAndRenderTask.close();
Như bạn có thể thấy điều đầu tiên bạn phải chuẩn bị các động cơ BIRT và sau đó nhận được một thể hiện của báo cáo từ loại IReportRunnable, vì vậy bạn có thể sau đó thiết lập các vị trí của đầu ra bằng cách sử dụng tùy chọn có phần sẽ được thay đổi dựa trên yêu cầu của bạn.
Bạn có nhiều lựa chọn, HTMLRenderOption, PDFRenderOption và các mục khác.
Tôi hy vọng rằng sẽ phục vụ bạn.
Cảm ơn.
Nguồn
2012-01-25 08:14:19
Câu trả lời tuyệt vời, một khoản tín dụng cho Stack Overflow. Hoàn thành và chính xác những gì đã được yêu cầu. Làm tốt lắm. – MystikSpiral
xem lại - hoạt động cho 4.2.2 cũng – Geronimo
Điều này phù hợp với BIRT 4.3.2 trong Tomcat 7. Nó không hoạt động trong Jetty cho 3.7.1 hoặc 4.3.2. – Ryan