UReport2:开源中式报表引擎

图片[1]-UReport2:开源中式报表引擎-山海云端论坛

UReport2是一款基于Apache-2.0开源协议的报表引擎,构建于Spring之上,纯Java开发,提供了高性能的报表引擎架构。通过迭代单元格,能够实现任意复杂的中式报表。

🌱 UReport2 主要功能和亮点

  • 完善的网页报表设计器: 提供了功能强大的基于网页的报表设计器,用户可以轻松快速地创建各种复杂的中式报表。
  • 跨浏览器支持: 在多种主流浏览器中运行良好,包括Chrome、Firefox、Edge等。
  • 兼容性: 在除IE浏览器之外的其他浏览器上,提供了良好的兼容性和用户体验。
  • 开源协议: 基于Apache-2.0开源协议,完全免费。

🍄 基于Maven的UReport2项目搭建

首先,需要创建一个标准的Maven项目。然后在项目的pom.xml文件中添加UReport2的依赖信息:

<code><dependency> <groupId>com.bstek.ureport</groupId> <artifactId>ureport2-console</artifactId> <version>2.2.2</version> </dependency></code>

同时,添加一个repository信息,告诉Maven从哪里下载依赖的包:

<code><repository> <id>sonatype</id> <url>https://oss.sonatype.org/content/groups/public/</url> </repository></code>

接下来,配置UReport2需要使用的servlet,在项目的web.xml文件中添加如下servlet配置:

<code><servlet> <servlet-name>ureportServlet</servlet-name> <servlet-class>com.bstek.ureport.console.UReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ureportServlet</servlet-name> <url-pattern>/ureport/*</url-pattern> </servlet-mapping></code>

在这个servlet配置中,url-pattern的值必须是”/ureport/*”。

接下来,根据项目中是否使用Spring,选择相应的配置方式:

  1. 如果项目中没有使用Spring,可以直接加载UReport2提供的配置文件。

在web.xml中添加Spring的listener,直接加载ureport-console-context.xml配置文件:

<code><listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:ureport-console-context.xml</param-value> </context-param></code>
  1. 如果项目中已经使用了Spring,可以在已存在的Spring配置文件中导入UReport2的配置文件。

在已有的Spring配置文件中添加如下配置:

<code><import resource="classpath:ureport-console-context.xml" /></code>
  1. 如果项目中没有Spring配置文件,可以在WEB-INF目录下新建一个名为context.xml的配置文件,并在其中导入ureport-console-context.xml配置文件。

context.xml文件内容如下:

<code><?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd "> <import resource="classpath:ureport-console-context.xml" /> </beans></code>

然后在web.xml中添加Spring提供的listener,加载context.xml文件:

<code><listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/context.xml</param-value> </context-param></code>

最后,运行项目,在浏览器中访问URL:

<code>http://localhost:8080/ureport-demo/ureport/designer</code>
图片[2]-UReport2:开源中式报表引擎-山海云端论坛

🎈 结语

UReport2提供了全新的基于网页的报表设计器,采用纯网页报表模板设计器,基于单元格迭代方式,能够快速开发各种类型的复杂中式报表。它能在Chrome、Firefox、Edge等各种主流浏览器上运行。使用UReport2,即可轻松完成各种复杂报表的设计制作。

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容