`
234390216
  • 浏览: 10193430 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
博客专栏
A5ee55b9-a463-3d09-9c78-0c0cf33198cd
Oracle基础
浏览量:460806
Ad26f909-6440-35a9-b4e9-9aea825bd38e
springMVC介绍
浏览量:1771803
Ce363057-ae4d-3ee1-bb46-e7b51a722a4b
Mybatis简介
浏览量:1395429
Bdeb91ad-cf8a-3fe9-942a-3710073b4000
Spring整合JMS
浏览量:393886
5cbbde67-7cd5-313c-95c2-4185389601e7
Ehcache简介
浏览量:678220
Cc1c0708-ccc2-3d20-ba47-d40e04440682
Cas简介
浏览量:529293
51592fc3-854c-34f4-9eff-cb82d993ab3a
Spring Securi...
浏览量:1178733
23e1c30e-ef8c-3702-aa3c-e83277ffca91
Spring基础知识
浏览量:461882
4af1c81c-eb9d-365f-b759-07685a32156e
Spring Aop介绍
浏览量:150144
2f926891-9e7a-3ce2-a074-3acb2aaf2584
JAXB简介
浏览量:66849
社区版块
存档分类
最新评论

JasperReport(1)——IReport的简单使用

 
阅读更多

JasperReport是一个用纯Java写的方便开发报表功能的开源软件。JasperReport的模版是类似于xml的格式,但是扩展名却是.jrxml。利用该模版就可以编译成.jasper文件,JasperReport就可以通过该.jasper文件生成相应的报表。

JasperReport的模版用手工来做的话是非常繁琐的,为此官方给我们提供了一个可视化工具叫IReport。

 

JasperReport生成报表的数据源可以是数据库、xml文件、excel文件等。而一般我们用IReport进行模版设计的时候用的比较多的还是利用数据库来设计。所以下面在使用IReport之前先给IReport设置一个数据源。




 

选择下一步

 


 

设置了数据源之后,我们就来建立一个简单的报表,但是该报表不会包含任何的数据源,只会有些简单的组件

选择文件->new ,打开新建页面,选择报表,如下图所示

 之后就一直下一步,就会打开一个刚刚建立的报表,模样如下图所示:

 


JasperReport是包含以下部分的:Title、Page Header、Column Header、 Detail、Column Footer、Page Footer和Summary,这几部分并不是每个部分都必须要的。

 

下面是一个通过左边的组件面板里面的static text组件生成的一个简单报表样式


生成的xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report3" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="44" splitType="Stretch">
			<staticText>
				<reportElement x="227" y="12" width="100" height="20" forecolor="#FF0000"/>
				<textElement textAlignment="Center">
					<font size="13" isBold="true"/>
				</textElement>
				<text><![CDATA[标题]]></text>
			</staticText>
		</band>
	</title>
	<pageHeader>
		<band height="35" splitType="Stretch">
			<staticText>
				<reportElement x="227" y="15" width="100" height="20" forecolor="#FF0000"/>
				<textElement textAlignment="Center">
					<font size="13" isBold="true"/>
				</textElement>
				<text><![CDATA[页眉]]></text>
			</staticText>
		</band>
	</pageHeader>
	<columnHeader>
		<band height="40" splitType="Stretch">
			<staticText>
				<reportElement x="227" y="12" width="100" height="20" forecolor="#FF0000"/>
				<textElement textAlignment="Center">
					<font size="13" isBold="true"/>
				</textElement>
				<text><![CDATA[相当于表头]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="44" splitType="Stretch">
			<staticText>
				<reportElement x="227" y="13" width="100" height="20" forecolor="#FF0000"/>
				<textElement textAlignment="Center">
					<font size="13" isBold="true"/>
				</textElement>
				<text><![CDATA[报表内容]]></text>
			</staticText>
		</band>
	</detail>
	<columnFooter>
		<band height="40" splitType="Stretch">
			<staticText>
				<reportElement x="227" y="10" width="100" height="20" forecolor="#FF0000"/>
				<textElement textAlignment="Center">
					<font size="13" isBold="true"/>
				</textElement>
				<text><![CDATA[相当于表尾]]></text>
			</staticText>
		</band>
	</columnFooter>
	<pageFooter>
		<band height="43" splitType="Stretch">
			<staticText>
				<reportElement x="227" y="13" width="100" height="20" forecolor="#FF0000"/>
				<textElement textAlignment="Center">
					<font size="13" isBold="true"/>
				</textElement>
				<text><![CDATA[页脚]]></text>
			</staticText>
		</band>
	</pageFooter>
	<summary>
		<band height="41" splitType="Stretch">
			<staticText>
				<reportElement x="227" y="10" width="100" height="20" forecolor="#FF0000"/>
				<textElement textAlignment="Center">
					<font size="13" isBold="true"/>
				</textElement>
				<text><![CDATA[用于存放一些统计信息的]]></text>
			</staticText>
		</band>
	</summary>
</jasperReport>

 这样一个简单的报表样式就出来了

  • 大小: 23.9 KB
  • 大小: 23.9 KB
  • 大小: 19.6 KB
  • 大小: 29.5 KB
  • 大小: 33.5 KB
  • 大小: 57.5 KB
  • 大小: 117.4 KB
  • 大小: 32.1 KB
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics