good_dou 2009-07-15 16:18
浏览 357
已采纳

iReport 导出word文档.doc格式 ?

怎么把iReport生成的报表导出为word文档格式.doc
我试了一下 只生成了报表图 没有文字和表格

-----------------------word
exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST,jasperPrintList);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"D://allreport.doc");
exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "GGB2312");
exporter.exportReport();

  • 写回答

1条回答 默认 最新

  • wanghaolovezlq 2009-07-15 16:25
    关注

    ireport 导出word格式
    导出word格式 在它的文档中也没有,

    // String sql = "select * from cfg_static_user_relation"; 如果传SQL语句的话用该句

    String ReportModel ="/test/test.jasper";

    File reportFile = new File(application.getRealPath(ReportModel));
    
    System.out.println(reportFile);
    if(!reportFile.exists())
         throw new JRRuntimeException("报表绘制失败,找不到报表配置文件!");
    JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
    

    // Connection conn=null;
    // conn=JdbcConnectionFactory.getConnection();
    Collection coll = UserService.generalCollecion();
    JRDataSource sor = new JRBeanCollectionDataSource(coll);
    System.out.println(application.getRealPath("test/1224215057359.png"));
    Map parameters = new HashMap();

       parameters.put("re",application.getRealPath("test/1224215057359.png"));
    

    // JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport ,parameters,conn);

        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport ,parameters,sor);
        JRExporter exporter = new JRRtfExporter();
    
        String tmpFilename = System.currentTimeMillis() + ".doc";
    

    response.setContentType("application/msword;charset=utf-8");
    response.setHeader("Content-Disposition", "attachment; filename="+tmpFilename);

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());

        exporter.exportReport();
    

    这样就可以导出WORD格式了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波