I'm using a Java bean as a datasource for my report and it's doing fine with normal types, but I have no idea how to use it for an image, searching on the web only gave me ways on how to do this using other data sources than a java bean, I'm using jasper soft
studio to design the reports.
This is how I usualy write the code for this:
Sample bean :
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;
}
}
print report method :
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 with byte u can solve that
private byte[] photo;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.