2017-07-14 42 views
0

我正在使用Java bean作爲我的報告的數據源,並且它對正常類型的性能很好,但我不知道如何將它用於圖像,搜索在網上只給了我如何使用其他數據源而不是java bean的方式,我使用jasper soft studio來設計報告。在jasper報告中使用java bean作爲數據源添加圖像

這是怎麼了我usualy寫這個代碼:

樣品豆

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(); 
     } 
    } 
+1

查看我的回答[在JasperReport中將字節數組顯示爲圖像](https://stackoverflow.com/questions/33547588/display-a-byte-array-as-an-image-in-a- JasperReport的)。 –

回答

0

MMM與字節u能解決那

私人字節[]照片;