当前位置:网站首页>Basic usage and FAQs of jasperreport report report generation tool
Basic usage and FAQs of jasperreport report report generation tool
2022-06-22 14:12:00 【Software testing Fairy】
JasperReports Introduce
JasperReport Is a powerful 、 Flexible report generation tool , Able to display rich page content , And turn it into PDF、HTML perhaps XML Format , The library consists entirely of Java Write , Can be used in a variety of Java Applications , Very suitable Java Developers use it to generate reports .

Basic guidelines
New projects

Select template first , Here we choose the ordinary one directly A4 Templates .

This is used to set the file name and file path .

Here is the data source selection , I have created the database connection in advance , It will be used when fetching data in subsequent tests .

Here is the JasperReport Main interface , First, let's introduce the five main areas of the interface :
Area 1: Select a data source and project ;
Area 2: The content list used to display the report , All component information contained in the report will be displayed here ;
Area 3: This is the visual report content area , Include report styles , Report source code and preview generation ;
Area 4: Component list ;
Area 5: Attribute editing area .
Let's introduce some basic attribute names that need to be used :
Parameters: Report parameters , Usually filled by external incoming data ;
Fileds: Field , Generated by the associated database or entity class ;
Vareables: Variable , It can be used for some mathematical calculations .
Finally, several modules of report content are introduced :
Title( title ): Display only at the top of the first page of the entire report , The other pages do not display ;
Page Header( Header ): It will be displayed on every page of the whole report , The first page is in Title Below the area , Each subsequent page is displayed at the top of the page ;
Column Header( The column header ):Detail If a table is printed in ,Column Header Is the column header of each column in the table ;
Deatil( details ): Report content , Data can be displayed circularly ;
Column Footer( Column foot ):Detail If a table is printed in ,Column Footer Is the footer of each column in the table ;
Page Footer( The footer ): Each page of the entire report will be displayed at the bottom , Generally used to display page numbers ;
Summary( total ): Appears on the last page of the entire report , stay Detail Back , It is mainly used for total display of reports .
Start the pictorial table

This is the source code of the project , I need to get some data from the product table here ,queryString In the tag is the retrieval of the main item sql, Add it directly .

Add... Here sql Then I got the product ID Field , The following will be displayed in the report , So in FIelds The domain also adds ID_PRODUCT Properties of , You can add... Directly to your code , You can also add... In the main interface , Here's the picture , Right click directly Create Field, And then in the area 5 Class and name can be modified in .


What we're going to do is Static Text and “Text Field” Drag in Detail In the region , One is static text , One is used to put attributes .

double-click Text Field, You can select the attribute we just added ID_PRODUCT, And change the static text to product ID, Our report can be generated preliminarily .

You can see that it has been generated successfully , I only go to the top ten data here , Here is another example of filtering data through external input data , Use the nature of the investment VLU_INVEST_PROPERTY This field , First, add the external input parameter of this field , And then sql Add the statement corresponding to the filter .

Then add this field to the main interface , To generate a report, you can filter the data according to the external input field .


Here, the basic operation process of template file generation has been introduced , This time is .jxml file , And then you need to build become .jasper file , You can go to java Call in program jasper Relevant methods generate reports .
common problem
Error as shown in the figure

This error is usually caused by mismatching between page width and column length .

stay xml The beginning of the source code will columnWidth Change to ratio pageWidth Just a small piece .
Some tables in the main interface cannot be displayed
It is very likely that the overlap of tables leads to , After separation .
No query results
In the use of table After component , After external data input sql The query has no results .
Because the external input data is not passed to the sub query , You need to set the transfer of values .


As shown in the figure, the value of the main project can be passed to table in .
Memory leak or overflow
You can use an emulator to solve the problem , Recommended JRGzipVirtualizer Emulator , Memory leaks can be compressed to a minimum .
Last :
You can go to my personal number :atstudy-js, You can get one for free 10G Software Test Engineer interview classic documents . And the corresponding video learning tutorial is free to share ! It includes basic knowledge 、Linux necessary 、Mysql database 、 Caught tools 、 Interface testing tool 、 Test advanced -Python Programming 、Web automated testing 、APP automated testing 、 Interface automation testing 、 Testing advanced continuous integration 、 Test architecture development test framework 、 Performance test, etc .
These test data , For doing 【 software test 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you !
边栏推荐
- How to add a mask to a VR panoramic work? What is the function?
- Stm32f1 and stm32subeide programming example - Optical intermittent sensor drive
- 30岁之前一定要明白的道理
- Performance of recommender algorithms on top-N recommendation tasks
- 聊一聊数据库的行存与列存
- Which securities company is good for retail investors to open an account? Is it safe to open a mobile account?
- Ppt data collection methods and analysis skills
- transformers VIT图像模型向量获取
- BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑
- 金融应用如何解决金额精度问题(以Quorum、golang为例)
猜你喜欢

Transformers vit image model vector acquisition

坚持了 10 年的 9 个编程好习惯

史蒂芬·柯维写给年轻人的高效工作秘笈

"N'osez pas douter du Code, vous devez douter du Code" notez une analyse de délai de demande réseau

程序员要不要选择软件人才外包公司?

技术实践 | 场景导向的音视频通话体验优化

"N'osez pas douter du Code, vous devez douter du Code" notez une analyse de délai de demande réseau

如何实现接口异常场景测试?测试方法探索与测试工具实现

Flink status management

“不敢去懷疑代碼,又不得不懷疑代碼”記一次網絡請求超時分析
随机推荐
Cve - 2022 - 22965 Resume
Rigid demand of robot direction → personal thinking ←
融云:让银行轻松上“云”
VR panoramic shooting breaks the deadlock of traditional propaganda that wild geese pass without leaving traces
如何实现接口异常场景测试?测试方法探索与测试工具实现
Flink状态管理
Understand the quality assurance of open source software (OSS)
Transformers vit image model vector acquisition
Oracle user space statistics
Tianrun cloud is about to be listed: VC tycoon Tian Suning significantly reduces his holdings and is expected to cash out HK $260million
Stephencovey's tips for efficient work for young people
20 good habits of outstanding professionals
Getting started with go web programming: validators
How to solve the problem of amount accuracy in financial applications (take quorum and golang as examples)
CVE-2022-22965复现
Talk about row storage and column storage of database
My suggestions on SAP ABAP transformation
BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑
Neuron+eKuiper 实现工业物联网数据采集、清理与反控
3dMax建模笔记(一):介绍3dMax和创建第一个模型Hello world