在jasper报告中使用javabean作为数据源添加图像

evrscar2  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(427)

我使用javabean作为我报告的数据源,它在普通类型上做得很好,但是我不知道如何将它用于图像,在web上搜索只为我提供了使用javabean以外的其他数据源来实现这一点的方法 jasper soft 工作室设计报告。
我通常是这样写代码的:
示例bean:

  1. public class SampleBean{
  2. String name;
  3. //image type?????!!
  4. public SampleBean( String name) {
  5. this.nom = nom;
  6. }
  7. public String getName() {
  8. return entrepriseNom;
  9. }
  10. public void setName(String name) {
  11. this.name= name;
  12. }
  13. }

打印报表方法:

  1. public void printReport() {
  2. try {
  3. Map<String, Object> params = new HashMap<String, Object>();
  4. InputStream stream = getClass().getResourceAsStream("sample.jasper");
  5. JasperReport report = (JasperReport) JRLoader.loadObject(stream);
  6. JasperPrint jasperPrint = JasperFillManager.fillReport(report, params, getData());
  7. JasperViewer.viewReport(jasperPrint, false);
  8. } catch (Exception e) {
  9. e.printStackTrace();
  10. }
  11. }
cpjpxq1n

cpjpxq1n1#

嗯,用u字节就能解决这个问题
私人照片;

相关问题