I want to render image from a folder and display in Excel report.
Following codes used to render.
String headerImagePath = "/file/fileName.jpg"
BufferedImage img = null;
try {
img = ImageIO.read(new File(headerImagePath));
} catch (IOException e) {
e.printStackTrace();
}
JasperReportBuilder report = report();
report.title(cmp.image(img));
But image is not showing in excel sheet.
Any other option to render an image?
Finally got it.!
You need pass the image file name as a parameter.
parameters.put("header", headerImagePath);
Add the above parameters & it's Class
to Jasper Report.
report.addParameter("header", String.class);
You can add the image to report as follows
report.title(cmp.image(exp.jasperSyntax("($P{header})",String.class)).setDimension(50, 130));