39

The windows installed on my machine has the locale en_AU and that's what JasperReports uses. I already tried changing the locale of all users, including the Administrator but it still uses en_AU.

How can I change that locale? Is it possible to change the REPORT_LOCALE parameter on my report?

4

3 回答 3

60

语言环境是在执行期间设置的,而不是在 JRXML 中。

使用 Java,REPORT_LOCALE为报表的参数映射设置参数。例如:

InputStream reportTemplate = getReportTemplate();
JRDataSource dataSource = getDataSource();

java.util.Map parameters = getParameters();
java.util.Locale locale = new Locale( "en", "US" );
parameters.put( JRParameter.REPORT_LOCALE, locale );

JasperFillManager.fillReport( reportTemplate, parameters, dataSource );

使用 Jaspersoft Studio,打开Report Execution区域的项目属性对话框:

项目属性

使用 iReport,在“常规”选项卡的“报告执行选项”部分下的“选项”窗口中设置报告区域设置。这将在运行时设置报告区域设置。

于 2009-04-21T12:48:21.517 回答
0

最简单的方法是net.sf.jasperreports.default.locale在文件中设置语言环境属性jasperreports.properties

于 2021-10-29T18:20:40.070 回答
0

JasperFillManager如果您不想更改代码,可以在执行代码的 JVM 上设置语言环境:

java -Duser.language=de -Duser.country=CH ...
于 2021-01-22T16:25:26.520 回答