birt 修改导出的文件名

birt 修改导出的文件名分两种实现方法,

第一种:修改 web.xml 中 配置的 BIRT_FILENAME_GENERATOR_CLASS

<!--
Filename generator class/factory to use for the exported reports.
-->
<context-param>
<param-name>BIRT_FILENAME_GENERATOR_CLASS</param-name>
<param-value>
org.eclipse.birt.report.utility.filename.TimestampFilenameGenerator
</param-value>
</context-param>

我是用的 TimestampFilenameGenerator ,那我们就直接修改它的getFilename方法.

public String getFilename(String baseName, String fileExtension, String outputType, Map options)
{
DateFormat dateFormatter = new SimpleDateFormat(this.datePattern);
if (fileExtension == null)
{
fileExtension = "";
}
ResourceBundle resource = ResourceBundle.getBundle("report_name_cn", Locale.CHINA);
try
{
baseName = new String(resource.getString(baseName).getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {
baseName = "未命名";
} return baseName + "_" + dateFormatter.format(new Date()) + "." + fileExtension;
}

第二种: 就是自己实现IFilenameGenerator 接口,并配置 BIRT_FILENAME_GENERATOR_CLASS

http://www.myexception.cn/open-source/727373.html

04-30 02:04