如何编译jrxml以获取jasper?

Moh*_*igh 67 java ant jasper-reports ireport jaspersoft-studio

在ant中,如何编译.jrxml文件以获取.jasper

Sal*_*ima 66

有三种方法可以将jrxml编译为jasper.

  1. 您可以通过iReport设计器上的编译按钮(锤子徽标)直接编译.

  2. 您可以使用ant进行编译,如Ant Compile Sample中所示.

    <target name="compile1"> 
      <mkdir dir="./build/reports"/> 
      <jrc 
        srcdir="./reports"
        destdir="./build/reports"
        tempdir="./build/reports"
        keepjava="true"
        xmlvalidation="true">
       <classpath refid="runClasspath"/>
       <include name="**/*.jrxml"/>
      </jrc>
    </target>
    
    Run Code Online (Sandbox Code Playgroud)

    下面是我当前项目的报告编译任务.

    替代文字

    此外,从丹尼尔Rikowski:

  3. 您还可以使用JasperCompileManager类从您的Java代码进行编译.

    JasperCompileManager.compileReportToFile(
                    "our_jasper_template.jrxml", // the path to the jrxml file to compile
                    "our_compiled_template.jasper"); // the path and name we want to save the compiled file to
    
    Run Code Online (Sandbox Code Playgroud)


Amo*_*ter 25

对于遇到这个问题的人,使用Jaspersoft Studio(我认为,它正在取代iReports;它非常相似,仍然是免费软件,仅基于eclipse),在你的编辑器区域顶部寻找"编译报告"图标. jrxml文件.它的图标,首先在该图标行中,是一个带有二进制数的文件(至少在5.6.2版本中):

Jaspersoft Studio  - 编译报告

单击此图标将在与.jrxml文件相同的目录中生成.jasper文件.


lec*_*ine 14

与maven它是自动的:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jasperreports-maven-plugin</artifactId>
        <configuration>
        <outputDirectory>target/${project.artifactId}/WEB-INF/reports</outputDirectory>
    </configuration>
        <executions>
            <execution>
                <phase>prepare-package</phase>
                <inherited>false</inherited>
                <goals>
                    <goal>compile-reports</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>3.7.6</version> 
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <type>jar</type>
    </dependency>
    </dependencies>
Run Code Online (Sandbox Code Playgroud)


Gré*_*ory 9

我正在使用iReport 2.0.2生成jasper文件.

我没有找到锤子徽标,但我create > compile在菜单栏中有一个菜单,他在iReport程序文件夹中创建了jasper文件:

IReport日志:"编译文章... ...\SalesOrderItemsSubreportA4.jasper - > C:\ Program Files\JasperSoft\iReport-2.0.2\SalesOrderItemsSubreportA4.java"


Luc*_*cky 6

在日食中,

  • 安装Jaspersoft Studio for eclipse。
  • 右键单击该.jrxml文件并选择Open with JasperReports Book Editor
  • 打开Design.jrxml文件的选项卡。
  • 在窗口顶部您可以看到Compile Report图标。


小智 5

使用iReport设计器5.6.0,如果您希望在不预览的情况下编译多个jrxml文件 - 请转到工具 - >大规模处理工具.选择Elaboration Type作为"Compile Files",选择存储所有jrxml报告的文件夹,并批量编译.