簡體   English   中英

在Jasper報告中使用Java bean作為數據源添加圖像

[英]adding image using java bean as a data source in jasper reports

我使用Java Bean作為報告的數據源,並且可以正常使用類型,但我不知道如何將其用於圖像,在Web上搜索僅提供了如何使用其他數據的方式源代碼比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();
        }
    }

mmm與字節u可以解決

私人字節[]照片;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM