A common question we get on the BIRT news group is how to change the
name of an exported document. For instance, exporting to PDF, the
developer may wish to have more control on what filename is used for the
export. Currently the name used is just the report name followed by
the emitter extension (eg MyReport.pdf).
BIRT 2.3.1 which will be
released later this month now supplies a solution to this problem. The
example web viewer has a setting that can be added to the web.xml that
allows you to specify a Java class that will be responsible for
generating the name.
<!-- Filename generator class/factory to use -->
<context-param>
<param-name>BIRT_FILENAME_GENERATOR_CLASS
<param-value>org.eclipse.birt.report.utility.filename.DefaultFilenameGenerator
</context-param>
The class specified must implement the IFilenameGenerator interface, which has one method named getFilename. This method is passed four parameters.
baseName – Contains the base filename for the report, with no extension provided.
fileExtension – The extension for the selected operation (ppt for export to PowerPoint).
outputType – The operation being executed. More on this parameter later.
options – Specific options for the operation.
The instance of the IFilenameGenerator is called in multiple locations within the example viewer. When you export the report:
When you export the report data:
And when you use the /document servlet mapping, for example:
http://localhost:8080/WebViewerExample/document?__report=OrderDetails.rptdesign
This URL will run the report and download the rptdocument.
Suppose you wish to have the date in your filename, when exporting the report. To do this, create a class with the following code:
package my.filename.generator; import java.util.Date; import java.util.Map; import org.eclipse.birt.report.utility.filename.*; public class MyFilenameGenerator implements IFilenameGenerator{ public static final String DEFAULT_FILENAME = "BIRTReport"; public String getFilename( String baseName, String extension, String outputType, Map options ) { return makeFileName( baseName, extension ); } public static String makeFileName( String fileName, String extensionName ) { String baseName = fileName; if (baseName == null || baseName.trim().length() <= 0) { baseName = DEFAULT_FILENAME; } // check whether the file name contains non US-ASCII characters for (int i = 0; i < baseName.length(); i++) { char c = baseName.charAt(i); // char is from 0-127 if (c < 0x00 || c >= 0x80) { baseName = DEFAULT_FILENAME; break; } } // append extension name if (extensionName != null && extensionName.length() > 0) { baseName += (new Date()).toString() + "." + extensionName; } return baseName; } }
If you check the source, you will notice this is just the default class with one modification.
baseName += (new Date()).toString() + "." + extensionName;
Which just inserts the date into the output.
You can also check the operation type if you wish to set the name based on the operation. Currently the available options for outputType are:
IFilenameGenerator.OUTPUT_TYPE_EXPORT – When exporting report to one of the supported formats.
IFilenameGenerator.OUTPUT_TYPE_DATA_EXTRACTION – When exporting report data.
IFilenameGenerator.OUTPUT_TYPE_REPORT_DOCUMENT – When using the document servlet mapping.
This example is located here .
Vincent Petry from the dev team has also uploaded a Birt Viewer 2.3 User Reference, which describes the settings and parameters available with the example web viewer. This document is informative and is located here .
If you wish to build your own version of the filename generator, make sure to include viewservlets.jar from the WebViewerExample\WEB_INF\lib directory in your build path.
相关推荐
解压到安装birt的eclipse对应文件夹中(plugins) 装好汉化包后 删除eclipse下的configuration目录里org.eclipse.update文件夹 再重启,选择Window->Preferences->BIRT->Preview选择你所需要的语言,再重启就可以了。
在本文中,我们将深入探讨如何实现BIRT报表的页面显示汉化,这涉及到对BIRT原有jar包中的英文资源文件进行替换,以显示中文界面。BIRT(Business Intelligence and Reporting Tools)是Eclipse基金会下的一个开源...
**Birt汉化版本适用于4.2到4.6** Birt(Business Intelligence and Reporting Tools)是一款开源的报告和商业智能平台,它允许开发者创建复杂的报表和数据可视化应用。这个汉化版本是针对Birt 4.2.2至4.6版本的,...
本资源是针对BIRT运行时环境的2.3.1和2.3.2版本的汉化语言包,旨在帮助中文用户更方便地使用BIRT进行报表设计和查看。 "birt-runtime2.3.1/2.3.2汉化包" 是针对BIRT运行时环境的中文语言支持,它包含了所有界面元素...
在IT行业中,BIRT(Business Intelligence and Reporting Tools)是一款开源的报表系统,广泛应用于Web应用程序中,用于生成复杂的业务报告。而JSP(JavaServer Pages)是Java平台上的动态网页技术,常用于构建用户...
在IT行业中,BIRT(Business Intelligence and Reporting Tools)是一款开源的报表系统,它允许开发者创建丰富的数据可视化和报告。在创建BIRT报表时,CSS(Cascading Style Sheets)样式起到了至关重要的作用,它们...
【标题】:“Pentaho CDE 整合 Birt” 【描述】: Pentaho CDE(Component Development Environment)是Pentaho BI平台中的一个工具,用于构建交互式的Web仪表板。它允许开发者通过拖放的方式创建数据可视化应用,...
Java Web项目集成开源报表工具BIRT 本文将指导读者如何将BIRT开源报表工具集成到已有的Java Web项目中,以Birt4.4.2为例。下面是具体的步骤和知识点: 步骤1:下载BIRT 首先,读者需要下载BIRT的最新版本。在BIRT...
#### 2.3.1 新建数据集 在“Data Explorer”中,右键单击“Data Sets”并选择“New Data Set”。选择数据源,编写SQL查询或使用Wizard来生成查询,添加需要显示的字段。 #### 2.3.2 创建表 同样,在设计区域拖放...
Eclipse BIRT(Business Intelligence and Reporting Tools)是开源的报告生成平台,主要用于开发复杂的报表和数据可视化应用。它被设计成可嵌入到各种应用程序中,支持Java和Web环境,提供了一个灵活的、基于组件的...
BIRT(Business Intelligence and Reporting Tools)是Eclipse基金会下的一个开源报表系统项目,主要用于生成复杂的商业报告和数据可视化。在Java环境下,BIRT提供了一套API和可扩展的框架,使得开发者可以轻松地将...
Eclipse 3.7 Birt 汉化包是一个针对Eclipse集成开发环境(IDE)中的Business Intelligence and Reporting Tools(BIRT)插件进行本地化的软件包。BIRT是一款开源的报告生成工具,允许开发者创建复杂的报表并嵌入到...
在BIRT(Business Intelligence and Reporting Tools)中添加JavaScript日期控件是提高报表交互性和用户体验的重要步骤。本教程将详细介绍如何在BIRT报告中集成My97DatePicker,一个流行的JavaScript日期选择器,以...
《BIRT API CHM》是关于BIRT(Business Intelligence and Reporting Tools)开发工具的重要参考资料,主要涵盖BIRT API的详细信息。BIRT是一款开源的报表系统,由Eclipse基金会维护,广泛应用于数据可视化和商业智能...
### BIRT报表设计基础知识点详解 #### 一、BIRT报表设计概览 **BIRT (Business Intelligence and Reporting Tools)** 是一款开源的商务智能和报表工具,主要用于开发和部署复杂的数据报表。它提供了丰富的功能来...
在IT行业中,BIRT(Business Intelligence and Reporting Tools)是一个开源的报表系统,它提供了一种强大的方式来设计、创建和展示各种数据报表。本话题主要关注如何利用BIRT API动态创建表格,这是一个在数据可视...
BIRT(Business Intelligence and Reporting Tools)是开源的报表系统,主要设计用于开发嵌入到Web应用程序中的报告。这个“birt中文帮助文档”压缩包包含了关于BIRT的详细信息,旨在帮助用户更好地理解和使用该工具...
**标题:Web项目集成BIRT** BIRT(Business Intelligence and Reporting Tools)是Eclipse基金会开发的一个开源报表系统,主要用于生成动态、交互式的报告。在Web项目中集成BIRT,可以帮助开发者提供强大的数据可视...
1. 打开 Eclipse 并转到“Help”>“Software Updates…”。 2. 在“Available Software”选项卡中,点击“Add Site...”按钮。 3. 输入 BIRT 更新站点的 URL([http://download.eclipse.org/tools/birt/updates]...