【问题标题】:adding image using java bean as a data source in jasper reports在 jasper 报告中使用 java bean 作为数据源添加图像
【发布时间】:2017-07-15 03:08:54
【问题描述】:

我正在使用 Java bean 作为我的报告的数据源,它在普通类型上运行良好,但我不知道如何将它用于图像,在网络上搜索只给了我如何做到这一点的方法使用除 java bean 之外的其他数据源,我使用jasper soft studio 来设计报告。

这就是我通常编写代码的方式:

样品豆

public class SampleBean{

    String name;
    //image type?????!!

    public SampleBean( String name) {
        this.nom = nom;
    }

    public String getName() {
        return entrepriseNom;
    }
    public void setName(String name) {
        this.name= name;
    }
}

打印报告方法

public void printReport() {
        try {
            Map<String, Object> params = new HashMap<String, Object>();
            InputStream stream = getClass().getResourceAsStream("sample.jasper");
            JasperReport report = (JasperReport) JRLoader.loadObject(stream);
            JasperPrint jasperPrint = JasperFillManager.fillReport(report, params, getData());                
            JasperViewer.viewReport(jasperPrint, false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

【问题讨论】:

标签: java image jasper-reports javabeans


【解决方案1】:

嗯,你可以用字节解决这个问题

私人字节[]照片;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多