ireport and Jasperreport Development detailed two

Source: Internet
Author: User
Tags bind expression interface modify net pack query window
Detailed  ireport and Jasperreport development two         3.2.1   Design report                   please click "DataSource" menu now Then select the "Read Query" item in, or click on the icon, and then ireport will pop up a dialog box (pictured): Now we enter SQL statement "SELECT * from Titles" in "SQL query" and then remove " Automatically Retrieve Fields "front of the hook, and then click" Read Fields "to read the data fields in the table as shown in the figure click" OK "to return to the main interface. Now the content of the design report, please click on the menu "View" under "Reports Fields" item, you can also click on the icon on the toolbar, and then you'll get all the field names in the table: You can select the columns you want, drag them, and drag the columns first into the report. So ireport will automatically bind the column you dragged (don't tell me you're not going to drag this action, OH), here we only make a simple, do not drag too many columns to the report, we only choose to take "title_id, Pubdate,title" three columns on it. Of course, if you do not want to use this simple method, to manually add that there is no way, you can also click on the toolbar icon, when your cursor will become a ten-shaped, you can draw a text box anywhere in the report, because you are in the report to draw a dynamic text column, then you have to set its properties, You can double-click the text box you just drew, or right-click on the text box you are drawing, and choose Properties. To set its properties. As shown in the figure: when the Properties window is opened by default, it is automatically transferred to the Text Field tab. At this point you have to set a data type corresponding to the database, this can not be wrong, otherwise you will compile or generate the report error (not tested, not sure that the error will occur in that step), There is also one we must pay attention to is "TextField expression", in its input box defaults to "$F {field}" then you need to change the "field" in the curly braces to the name of the column you want to specify in the table. If you want to ask what "$F" stands for, you should look at the following tableIt's time to know. After you set up these two, you can bind a column of data. But you have to put it in the "detail" area, or you may be able to display only one record to the report when you run the report. Why don't you just interpret it? The empty page of the entire report ireport has divided the location of the data for you, such as: "Title,pageheader,columnheader" and so on. Element name reference variable Variablesname $V {variablesname} parameter parametername $P {parametername} field Filedsname $F {filedsname}  &N bsp;       run the report now always feel a bit monotonous, we can set some titles such as the report of information, found in the toolbar, click it and then in the "Title" area to draw a text box, double-click it or click the right key to select Properties now appears in a Static text Box property window, select the "Static Text" tab, enter "test Report", you can select in the Font tab you want to see fonts and font size, as shown here you also can not enter, You can also populate it by fetching data from the database. With all the "common" tab, after clicking, you will see "Print when expression" in its input box in the input you want the name of the column, the specific operation as above, also from the right side of the three-pointed icon to enter, there are four types of " Fields,parameters,variables,formulas "Here only the first two," Fields "in the previous said, the specific operation is the same, no longer elaborate, the second" Parameter "This parameter is generally not used in the ireport , and then talk about it later. Then according to set "title" Way to Set "ColumnName", do you see the Chinese display does not come out, or garbled, how to do?    You can see the FAQ at the bottom of the page, and now a basic report can be thought to be done, but you have to adjust its position and the upper and lower boundary lines, otherwise the data will be very fragmented when displayed on the page. Save it now, and remember it's best to save it as you did when you created the report. Reason: "Because a file stream is used to read a report, and then an error occurs when compiling." After saving, click on the toolbar icon to compile, there are two icons on the toolbar one is for static reports, and the other is used to populate the dynamic report, now we can only use the dynamic Report execution button to populate the report, the former to execute the words in addition to your static text, other display Null ireport is "Jrviewer Preview" by default, and the resulting effect is:         you can also "build" menu to choose the format you want to report, such as: pdf,xsl,csv,html ... When you choose, if you do not specify the running program that you specify to generate the report, it will be saved to ireport's current directory, not in the directory where you saved the report. If you don't like the English interface, you can set the language, save the location of the report, the backup location, the program to run the report, and so on under the menu "Tools". To be continued   faq        1. When the report is generated, is the Chinese generated garbled?              Jasperreport's Chinese processing requires an Asian language pack. Itextasian.jar, "to the Lib directory under ireport, and then modify the report's PDF Font Name to" Stsong-light ", and then modify PDF Embedded PDF Encoding To change it to" Unigb-ucs2-h (Chinese Simplified) ", so that you can solve the problem of Jasperreport Chinese (for the PDF set, for Excel may be less, but this setting also can be displayed as Chinese, is not like to lead the ring).         2. noclassdeffoundexception exceptions are generated when the report is compiled?               This exception occurs when code handles jasperreport because some jar files that refer to Jasperreport are incomplete. Due to work busy my way is to Jasperreport directory of the demo ample\webapp\web-inf\lib\ all the jar files, all cited, safekeeping, but also no time to too much to delve into. OneThere will be some unnecessary bags to be quoted, if you have time to look, and then remove unnecessary jars.         3. Unisupportencodingexception exception occurred while saving as PDF?               in the report design process will inevitably have a small error, this is because the "PDF Font Name" should be changed to " Stsong-light ".   download Related:         ireport download address: http:// Ireport.sourceforge.net        jasperreport Download Address: http:// Jasperreports.sourceforge.net        itext Asian language Pack download address: http:// Www.lowagie.com/iText

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.