JasperReports中的外部样式 [英] External Styles in JasperReports

查看:137
本文介绍了JasperReports中的外部样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含大量报告的系统,使用 JasperReports的。其中一个较新的功能是您可以为报告定义样式。

I'm working on a system that includes a large number of reports, generated using JasperReports. One of the newer features is that you can define styles for reports.

从可用的文档中我相信有一些方法可以使用定义样式的外部文件,以及你可以在你的jasper报告中引用它。这允许多个报告使用单一样式。

From the available docs I believe there is some way to have an external file defining styles to use, and you can reference that in your jasper reports. This allows a single style to be used by multiple reports.

我找不到关于这是否是实际特征的任何具体信息,如果是,如何用它。有没有人知道是否可以为jasper报告设置外部样式,如果有,怎么做?

I can't find any concrete information on whether this is an actual feature, and if it is, how to use it. Does anyone know if it is possible to have external styles for jasper reports, and if so, how to do it?

推荐答案

使用 JasperReport模板。 JasperReports模板是以 .jrtx 结尾的模板,可能看起来与此类似( styles.jrtx ):

Use JasperReport templates. A JasperReports template is one that ends in .jrtx, and may look similar to this (styles.jrtx):

<?xml version="1.0"?>
<!DOCTYPE jasperTemplate
  PUBLIC "-//JasperReports//DTD Template//EN"
  "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">

<jasperTemplate>
    <style name="Report Title" isDefault="false" hAlign="Center" fontSize="24" isBold="true"/>
    <style name="Heading 1" isDefault="false" fontSize="18" isBold="true"/>
    <style name="Heading 2" isDefault="false" fontSize="14" isBold="true"/>
</jasperTemplate>

然后在你的 .jrxml 文件中,将其作为模板包含在内:

and then in your .jrxml file, include it as a template:

...
<template>"styles.jrtx"</template>
...

iReport也理解这一点,因此您的样式会被导入并显示在iReport中正确(虽然我有时会注意到它不会重新加载或重新编译是必要的)。

iReport also understands this, so your styles are imported and shown in iReport correctly (though I did notice sometimes it wouldn't pick them up an a reload or recompile was necessary).

这篇关于JasperReports中的外部样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆