java 如何从编译的 .jasper 文件创建 JasperReport 对象?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9907489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 22:50:12  来源:igfitidea点击:

How to create JasperReport object from compiled .jasper file?

javajasper-reports

提问by marioosh

I have compiled report (.jasperfile). I need to get some info from that object (for example report name). How to do that ? If I could create JasperReportobject, i can call getName()method on it, but I don't know how.

我已经编译了报告(.jasper文件)。我需要从该对象获取一些信息(例如报告名称)。怎么做 ?如果我可以创建JasperReport对象,我可以调用getName()它的方法,但我不知道如何。

回答by Jacob Schoen

You can get the JasperReport object by doing:

您可以通过执行以下操作获取 JasperReport 对象:

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(new File("filename.jasper"));

from there you can get the name by doing:

从那里您可以通过执行以下操作来获取名称:

jasperReport.getName()