Topic: jasperreport如何与javabean配合制作报表?

  Print this page

1.jasperreport如何与javabean配合制作报表? Copy to clipboard
Posted by: wangleilei
Posted on: 2003-07-24 10:05

jasperreport做报表一般是自己写连接和查询语句来得到数据填写入报表,
如果数据已经找到,并且存放在一个javabean中。在一个jsp中引用这个
javabean,那么怎么样将这个javabean中的数据填写入jasperreport的报表中

请做过jasperreport的高手解答?

2.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: hitdemo2002
Posted on: 2003-07-24 10:42

你可以看看jasperreports-0.5.0/demo/samples/datasource这个例子,自己照着改一下就行了。
就是说可以类似这样
StuBean stubean = studata.getOneStu(stuId);
StuBean[] data = { stubean};
StuBeanFactory beanfactory = new StuBeanFactory(data);
//填充-具体填充
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,new JRBeanCollectionDataSource(StuBeanFactory.getBeanCollection()));

3.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: wangleilei
Posted on: 2003-07-25 14:25

to :hitdemo2002
不是很明白那一个才是你自己定义的javabean?

4.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: jackzhuo
Posted on: 2003-07-27 12:20

请问JasperReport可以采用web的方式生成报表吗?我现在有个项目需要使用到报表,我试过StyleReport和JReport,虽然功能都非常强大,但毕竟需要破解才可以使用,如果只是自己学习一下还没有什么问题,要是用在项目中总觉得的不太好,所以希望找一些免费的软件来用,找到JasperReport后,由于没有多少文档,不太好入手!

如果你们做过的,能否给小弟一些文档或指点一下迷精?谢谢!

5.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: wangleilei
Posted on: 2003-07-28 08:47

to :jackzhuo
JasperReport是可以做web方式的报表的!
-- Quick Start for JasperReports (webapps Demo)
--------------------------------------------------------------------------------
Notes:
- Assume Tomcat 4.0 is being used.
- Assume Tomcat is installed in local machine with listening port 8080.
- Assume JasperReports 0.4.3 is being used.

1. Download JasperReports project file.
Get JasperReports project file, jasperreports-X.X.X-project.zip from
SourceForge (URL: http://sourceforge.net/project/showfiles.php?group_id=36382).

2. Decompress the project file.
Decompress the project file to your harddisk. Let's said <jasper dir>.

3. Deploy the JasperReports webapps Demo to Tomcat.
3.1. Copy <jasper dir>\demo\samples\webapp to
<tomcat dir>\webapps
So, you should have a directory:
<tomcat dir>\webapps\webapp
3.2. Define Context Name for JasperReports webapps Demo
* This step is optional. The intention is defined a more meaningful
context name for this JasperReports sample.
Rename <tomcat dir>\webapps\webapp to
<tomcat dir>\webapps\jasper
3.3. Start your Tomcat.

4. Launch JasperReports webapps Demo via browser with URL:
http://localhost:8080/jasper

5. Compile Sample Reports
5.1. Go to compile page with URL:
http://127.0.0.1:8080/jasper/compile.html
5.2. Click hyperlink "execute" for JSP Example at the bottom.
5.2. Click hyperlink "execute" for Servlet Example at the bottom.

6. Run the Sample Reports
6.1. Get reports in PDF from URL: http://127.0.0.1:8080/jasper/pdf.html
OR
6.2. Get reports in HTML from URL: http://127.0.0.1:8080/jasper/html.html
OR
6.3. Get reports in Applet from URL: http://127.0.0.1:8080/jasper/applets.html

--------------------------------------------------------------------------------
-- 2003-JAN-23 Julian13@http://www.cjsdn.com
--------------------------------------------------------------------------------

6.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: hitdemo2002
Posted on: 2003-07-29 08:28

StuBean 是自己定义的bean
StuBeanFactory的代码类似:
--------------------------
import java.util.*;
import com.gctx.develop.bean.StuBean;

public class StuBeanFactory {

private static StuBean[] data;
private static ArrayList datas;

public StuBeanFactory(StuBean[] data) {

this.data = data;

}

public StuBeanFactory(ArrayList datas) {

this.datas = datas;

}

public static Object[] getBeanArray() {
return data;
}

public static Collection getBeanCollection() {
return Arrays.asList(data);
}

}
--------------------------------------------

7.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: jackzhuo
Posted on: 2003-08-05 10:26

To: wangleilei
谢谢!

前几天我看了一遍JasperReport的文档,写的非常好,看完了以后我就没有了现使用什么JReport或StyleReport的想法了! SmileSmile

8.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: wangleilei
Posted on: 2003-08-09 16:03

to:hitdemo2002

谢谢!!前2天去徐州出差了,没有看到你的帖子

9.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: hi_liuyang
Posted on: 2003-08-15 10:11

jasperreports连关系型数据库出报表也要每张报表作一个bean吗?

我使用ireport制作jasperreports可视化编辑xml好后,jasperreport数据源怎么配?

10.Re:jasperreport如何与javabean配合制作报表? [Re: wangleilei] Copy to clipboard
Posted by: hi_liuyang
Posted on: 2003-08-15 10:20

是否是:
JasperFillManager.fillReportToFile(fileName, parameters, getConnection());


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923