开发者

Can data in a java text field be sent to jasper report without database interaction?

开发者 https://www.devze.com 2023-04-05 00:36 出处:网络
We are developing a desktop application in java using netbeans. we have installed the jasper reports for netbeans and are able to design the reports from the data in the database

We are developing a desktop application in java using netbeans. we have installed the jasper reports for netbeans and are able to design the reports from the data in the database

There is a form which we want to print without storing the data in the database. Can we send the form data into jasper report?

Please expla开发者_StackOverflow中文版in


Yes. If it's just one value, you just have to set it in the parameters map of the report, and access it using $P{foo} (meaning the value is tored in the map, at the key "foo"). If it's a list of values you want to iterate on in the details band of the report, You may use a JRBeanCollectionDataSource.

You'll be able to access each property (throught its getter method) of the beans in the collection: $F{foo} will call your bean's getFoo() method to get the field value.


  1. install IReport plugin in netbean IDE
  2. Create Java Project and then create JavaBean class in this project
  3. After clean and build project you to netbean menu Tool and go to Option after open option goto irepot tab and set classpath and add netbean JavaBean project Jar Path Like if create Project HelloBean mean that jar name HelloBean.jar u your hellobean.jar and add it in your ireport class path.
  4. after open your ireport you go!

check images here

Can data in a java text field be sent to jasper report without database interaction?

Can data in a java text field be sent to jasper report without database interaction?


para.put(<key>,<value>);
para.put(<key>,<value>);
para.put(<key>,<value>);

JasperFillManager.fillReportToFile(jr, para, new JRemptyDataSource());

if you don't write new JRemptyDataSource() a message will appear that the document has no pages and inside your report create a field and in field expression put your parameter (the parameter name should have the same key value )

0

精彩评论

暂无评论...
验证码 换一张
取 消