First, you need to install Ant, pay attention to not forget to set PATH in Path, for example, Ant installed in my system is d: / apache-Ant-
1.6.2
Then set the environment variable in Path. The next thing is to download JasperReport. Download that with Demo, uncontrolled him, and the previous work is completed.
Open / JasperReport / Demo / Samples, here is all the examples of the official offer:
1. Alterdesign
Running this example with Ant exhibits the overall workflow of JasperReport, while displaying how PDF files generate, the background color is controlled. First, you have to understand the working principle of JasperReport. It turns out that it is based on an XML file. If you use Ireport, you will use it to generate this XML file), so in AlterDesign, we only need to keep alterdesignapp.java (this It is a Java source file, you don't have to say); build.xml This is Ant needs, about the writing method of the file, I want to don't have to die, if you want to use, find a template COPY, or see http : //Dev.9cbs.net/develop/article/65/65567.shtm knows that it is probably; alterDesignreport.jrxml, this is what we just said, this is also necessary. We can delete the rest of the document (note that it refers to AlterDesign), that is, our example will win 3 files. Now start using Ant, enter the directory at the command prompt, first knocking with Ant Javac, don't use me, compile this java file, now there is .class; second step to attack Ant Compile, this step is actually Called compilation, it is a JasperReport engine to compile the XML file, generate something that is against the parole, this we don't care as long as you have an alterdesignreport.jasper generation; the third step is knocked into Ant Fill, as the name, The filler of the report generates alterDesignreport.jrprint; the last step ANT PDF or Ant View or Ant Print, the previous one is to generate the PDF file, the middle one is previewed in SWING, and the latter is called the print interface. Ok, is it very clear about the entire workflow? You can see AlterDesignapp.java now, it is true.