若依前后端分离框架集成UReport2,保存至数据库并结合业务使用导出

一.UReport2概述:

        UReport2是一款基于架构在Spring之上纯Java的高性能报表引擎,通过送代单元格可以实现任意复杂的中国式报表。相比UReport1UReport2重写了全部代码,弥补了UReport1在功能及性能上的各种不足。在UReport2中,提供了全新的基于网页的报表设计器,可以在Chrome、Firefox、Edge等各种主流浏览器运行 (E浏览器除外) 。使用UReport2打开浏览器即可完成各种复杂报表的设计制作。

 文档视频教程地址:

  1. BSDN WIKI: http://wiki.bsdn.org/display/UR/ureport2+Home
  2. w3cschool: https://www.w3cschool.cn/ureport

二.安装配置

1.pom.xml文件中引入ureport2的依赖



	com.bstek.ureport
	ureport2-console
	2.2.9

2.启动类指定xml文件,注册Bean

@ImportResource("classpath:ureport-console-context.xml")
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication {
    public static void main(String[] args) {
        SpringApplication.run(RuoYiApplication.class, args);
        System.out.println("(♥◠‿◠)ノ゙  若依启动成功   ლ(´ڡ`ლ)゙  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
    }

@Bean
    public ServletRegistrationBean buildUReportServlet(){
        return new ServletRegistrationBean(new UReportServlet(),"/ureport/*");
    }

3.根据@ImportResource(“classpath:ureport-console-context.xml”)指定,创建context.xml文件



 
    
    
        
            classpath:config.properties
        
    

若依框架配置层级目录:ruoyi-admin\src\main\resources\context.xml

如果为springboot框架整合,放在resources下即可。

4.根据context.xml指定位置创建ureport配置文件。名为config.properties

ureport.disableHttpSessionReportCache=false
ureport.disableFileProvider=true
ureport.fileStoreDir=/WEB-INF/ureportfiles
ureport.debug=true

5.在ruoyi-framework模块SecurityConfig.java类中加入运行匿名访问,将拦截排除

若依前后端分离框架集成UReport2,保存至数据库并结合业务使用导出

 此时后端配置完成。启动项目,下图为启动成功。

若依前后端分离框架集成UReport2,保存至数据库并结合业务使用导出

 访问http://localhost:8080/ureport/designer即可。 

若依前后端分离框架集成UReport2,保存至数据库并结合业务使用导出

 三.前端配置

1.在ruoyi-ui/vue.config.js添加下列代码

'/ureport': {
    target: 'http://localhost:8080',
    ws:false,
    changeOrigin: true,
    pathRewrite: {
        '^/ureport': '/ureport'
    }
}

 位置如下

若依前后端分离框架集成UReport2,保存至数据库并结合业务使用导出

2.在views目录下创建ureport/designer,新增index.vue文件。

层级目录:src\views\ureport\designer\index.vue