Dynamic Jasper: Image not displayed after exporting as XLSX

0

I'm using JRXlsxExporter to export my JasperReport to XLSX format. To create the output stream, I'm opening up a blob stream and setting it to the SimpleOutputStreamExporterOutput. The blob is then saved to the DB after the exporter.exportReport() method is called.

OutputStreamExporterOutput simpleOutputStreamExporterOutput = new SimpleOutputStreamExporterOutput(blob.setBinaryStream(1));

The problem is, there is a jpg image part of the report content. When the report is exported to XLSX, 'The image cannot be displayed' message shows up in the xlsx in place of the image, but the rest of the data comes up fine.

I tried using a FileOutputStream instead of the blob stream and everything including the image comes up fine in the exported xlsx. But since I cannot be saving the exported report files on the application servers, and since I have to write to the DB as a blob, I would most definitely want to use the blob stream.

  • Jasper reports version - 6.2.0
  • Dynamic Jasper version - 5.0.4

I'm using the DynamicReportBuilder addFirstPageImageBanner() method to add the image. Here's the code to add the image:

drb.addFirstPageImageBanner("imagepath" + "imagename", new Integer(197), new Integer(53), ImageBanner.ALIGN_LEFT);

Here's part of my jrxml file as well. But I'm not using the image tag in the jrxml to add the image though, it is being done with the above method.

<title>
<band height="30"/>
</title>
<pageHeader>
<band height="141">
<textField>
<reportElement x="0" y="78" width="290" height="78"/>
<textElement>
<font fontName="Times New Roman"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{reportInfo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="58" width="290" height="20"/>
<textElement>
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{reportType}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="38" width="290" height="20"/>
<textElement>
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{reportTitle}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="290" height="38"/>
<textElement>
<font fontName="Times New Roman" size="18" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{title}]]></textFieldExpression>
</textField>
</band>
</pageHeader>

Is this a known bug with the 6.x release, with the Blob output stream? Coz it used to work for us fine with the 3.x release.

Any help is deeply appreciated. Thank you!

amithleeladamodaran's picture
Joined: Dec 2 2016 - 1:41pm
Last seen: 4 years 9 months ago

0 Answers:

No answers yet
Feedback
randomness