学会JasperReport报表导出以后再也难不倒我们了

一个空的模板页,有类似html的title detail等元素

本节主要讲解模板设计中如何放置模板元素达到我们想要的效果,涉及到模板元素的使用,如detail,column header等,下面将一一讲解outline中各个自带元素的使用


Tille

标题 Title在第一页中显示,而第二页和第三页都不会再显示,所以Title只会显示一次。

Detail

则是要放置填充数据的位置,因为它会加载多次,有多少条数据就会加载多少次,保证了数据可以全部显示出来。

Page Header

顾名思义,页的头部,应该就是我们所说的页眉,我们的word文档一般都会有页眉, Page Header会在每一页都加载一次,与Detail作用一致

Column Header & Column Footer

首先看名字,表头与表尾,作用与Page Header应该相差无几,都是提示文字,表头可以放表格里列的名字,表尾可以放一些数据的总结概括等等。

在Column Header 和 Column Footer各自放置两段Static Text,然后进行预览。


Page Footer

有了页眉,自然有对应的页脚。一般页脚的作用都是用于显示页数的

Last Page Footer

Page Footer是没法显示最后一页的。幸好还有一个元素,Last Page Footer,这个元素就是用以最后一页页脚的

Summary

Summary是数据显示完之后用以总结的,并且会出现在Detail表格下方

No Data

不知道是干什么的

Background

Background应该是报表的背景

官方文档说明

TITLE

This is the first section of the report. It is generated only once during the report-filling

process and represents the beginning of the resulting document.

The title section precedes even the page header section. To print the page header before

the title section, put the elements on the page header at the beginning of the title section

as well. You can suppress the actual page header on the first page using the

《printWhenExpression》, based on the PAGE_NUMBER report variable.

As described in “Report Template Properties” on page 42, the title section can be

followed by a page break if the isTitleNewPage attribute is set to true.

PAGE HEADER

This section appears at the top of each page in the generated document.

COLUMN HEADER

This section appears at the top of each column in the generated document.

DETAIL

For each record in the data source, the engine tries to generate this section. The detail

section can be made of multiple bands.

COLUMN FOOTER


This section appears at the bottom of each column in the generated document. It never

stretches downward to acquire the content of its containing text fields. Its rendering

position is controlled by the isFloatColumnFooter flag declared at report template

level.

PAGE FOOTER

This section appears at the bottom of each page in the generated document. Just like the

column footer section, the page footer never stretches downwards to acquire the content

of its containing text fields and always retains the declared fixed height.

SUMMARY

This section is generated only once per report and appears at the end of the generated

document, but is not necessarily the last section generated. This is because in some cases

the column footer and/or page footer of the last page follows it.

As mentioned in “Report Template Properties” on page 42, you can have the summary

section start a new page of its own by setting the isSummaryNewPage attribute to true.

Even if this attribute remains false, the summary section always starts a new page if it

does not fit on the remaining space of the last page, or if the report has more than one

column and it has already started a second column on the last page.

LAST PAGE FOOTER

If present, this section replaces the normal page footer section, but only on the last

occurrence of the page footer, which might not be the last page if the summary is present

and it overflows on multiple pages or it is rendered alone on its own last page. So it

behaves more like the last page footer than the footer of the last page.

BACKGROUND

This is a special section that is rendered on all pages and its content placed underneath

all other report sections. Normal report sections are rendered one after the other, but the

background section does not interfere with the other report sections and can be used to

achieve watermark effects or to create the same background for all pages.

If the main report sections described here don’t meet your needs, you might consider

introducing supplementary sections like group headers and group footers.

The following section shows how to group data on the report.

NO DATA

This is another special section that is generated only once per report and, under certain

conditions, its content will replace all the ordinary report’s content.

Sometimes when the report data source is empty, is very useful to generate an equivalent

content, a notice, maybe, or an image, in order to replace all the empty zone. Especially

in the case of subreports, more useful is to replace all the subreport’s content with an

equivalent one.

If the ‘noData’ section is defined in the report template, and if the data source is empty,

then the ’noData‘ section will be the only one taken into account at fill time, and its

content will produce the report output.

jasper导出图表


一个简单的柱状图, 怎么配置属性呢 在图表右键选择Edit Chart Wizard


Series

代表x轴每一个所对应的柱子个数, 也就是红蓝青三条柱子, 如果想要更多点击右侧...选择add即可

Category

x轴显示的值

Value

自然就是数量了

Label

单词意思是标签, 但是加了没发现有什么用不加会报错

X轴如何倾斜

点击图表在右侧Properties中找到 Chart Plot > Category Axis Tick Label Rotation 选择倾斜角度即可


大家都知道在数据量大的情况下x轴如果不倾斜一个个字挤的可是很难看的, 话说我也是找了好久才找到这个属性

最后要注意的一点


必须为这两个选项下的所有Font标签设置字体不然中文可是无法显示的,  就像这样


PDF显示中文问题项目中配置, PDF显示中文问题传送门

jasperreports_extension.properties

net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory

net.sf.jasperreports.extension.simple.font.families.lobstertwo=fonts/fonts.xml




此人博客有更详细jasper教程

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,185评论 6 503
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,652评论 3 393
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,524评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,339评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,387评论 6 391
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,287评论 1 301
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,130评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,985评论 0 275
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,420评论 1 313
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,617评论 3 334
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,779评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,477评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,088评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,716评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,857评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,876评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,700评论 2 354

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,324评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,491评论 0 23
  • 轻轻捻开最后一页 并不是结束而是新的开始 不能释卷对你的阅读 最伤的痛在折磨 就是不能放弃 那毫无结果的等 我愿意...
    营州布衣阅读 140评论 2 10
  • 我比谁都感到无以复加的幸福 澎湃 汹涌 我活出了自我 无与伦比的自我 刀枪不入的自我 钢筋铁骨的自我 独立自强的自...
    欣昉阅读 163评论 0 0
  • 慢慢的才知道太在乎别人的感受往往会伤害自己。 慢慢的才知道很多东西是可遇而不可求的。 慢慢的才知道很多时候遇到不顺...
    哒哒鸡腿阅读 146评论 0 1