使用jar文件中存在的.jasper文件 [英] Using a .jasper file present within a jar file

查看:250
本文介绍了使用jar文件中存在的.jasper文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 JasperReports 作为我们的报告工具。之前我们使用
jasper文件的相对路径来填充报告,它工作正常。

We are using JasperReports as our reporting tool. Earlier we were using relative paths for jasper files for filling report and it's working fine.

现在,我们要为所有已编译的<$创建一个新的jar c $ c> jrxml 文件。即包含我们项目的所有 .jasper 文件的jar。

Now, we want to create a new jar for all compiled jrxml files. i.e a jar containing all .jasper files for our project.

有没有办法访问那些<$ c填写报告时,$ c> .jasper jar文件中的文件。因为在文档中,我总是看到

Is there a way to access those .jasper files within a jar file while filling report. Because in documentation, i always see

fillReport(java.lang.String sourceFileName,java.util.Map params)

其中,sourcefile始终是文件系统上的路径。

where, sourcefile is always a path on filesystem.

我的问题是,有没有办法访问jar文件
中存在的已编译 .jasper 文件并根据这些文件填写报告?

My question is, is there a way to access compiled .jasper files present within a jar file and fill report based on those files ?

编辑:
基本上需要的是,我需要从jar文件中访问 .jasper 文件,然后使用该文件填充报告 .jasper 文件并将生成的报告保存到文件系统中。

Essentially what is required is, i need to access .jasper files from a jar file, and then fill reports using that .jasper file and save the generated reports onto a filesystem.

推荐答案

大多数值得使用的API都会提供重载方法来接受输入流。例如。 JasperFillManager.fillReport(InputStream,Map)

Most APIs worth using will provide overloaded methods to accept input streams. E.G. JasperFillManager.fillReport(InputStream, Map)

进入 InputStream ,使用 Class.getResourceAsStream()

这篇关于使用jar文件中存在的.jasper文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆