Issue with Aspose.Words and JasperReport Integration and export report to word

Hello support,

I’m currently working with JasperReport 6.20 to generate reports. Additionally, I’m using Aspose version 23.9 along with the Aspose.Words.jasperreports library (version 7.8.0-8.0.0) for report exporting to Word format.

The problem I’m facing is that when I export my report to Word, the header and footer content is not retained in the Word document, even though they appear correctly in the Word file. This issue is evident in the attached screenshot.

I would appreciate any assistance in resolving this matter.
you can fin attached the screenshot .

Best regards.

Here’s a rephrased version of your provided case for better understanding:


<?xml version="1.0" encoding="UTF-8"?>
<pageHeader>
   <band height="99" splitType="Stretch">
      <subreport isUsingCache="true" runToBottom="false">
         <reportElement x="10" y="20" width="500" height="60" forecolor="#FFFFFF" uuid="0886ac7a-b476-4363-8874-bd329f0eac21" />
         <subreportParameter name="mapEntite">
            <subreportParameterExpression><![CDATA[$P{mapEntite}]]></subreportParameterExpression>
         </subreportParameter>
         <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{datasourceEntete}.getData())]]></dataSourceExpression>
         <subreportExpression><![CDATA[$P{patronEntete}]]></subreportExpression>
      </subreport>
   </band>
</pageHeader>

In this scenario, the issue is that the subreport is visible, but it does not appear in the header section of the Word document.

If a simple textField appears correctly in the header while a subreport does not, there might be a compatibility or configuration issue specific to how subreports are handled in the context of exporting to Word documents.

<?xml version="1.0" encoding="UTF-8"?>
<pageHeader>
   <band height="99" splitType="Stretch">
      <!-- Using a textField instead of a subreport -->
      <textField>
         <reportElement x="10" y="20" width="500" height="60" forecolor="#FFFFFF" uuid="0886ac7a-b476-4363-8874-bd329f0eac21" />
         <textFieldExpression><![CDATA[$P{patronEntete}]]></textFieldExpression>
      </textField>
   </band>
</pageHeader>

In this example, I’ve replaced the subreport with a textField to see if it resolves the issue. If the textField works correctly in the header, it suggests that the problem might be related to how subreports are handled or configured during the export to Word. You may need to review the compatibility of subreports with Word export or check if there are any specific settings or configurations required for subreports in this context.

@Mouna87 We will check the issue and get back to you soon.

Hi @Mouna87

You right and Aspose Words for JasperReport can’t include subreport in header and footer.
I worked on similar problem in Header and footer on the loose after upgrade

In all my tests with header/footer subreports, Header subreport contains his pageHeader and
We use AWExporterParameter.PROCESS_SUBREPORT_HEADER_AS_HEADER for recognizing header in subreport and use it instead of main header.

I think that your solution with TextField is best way to solve this problem.

Hello @anatoly.sidorenko ,

thanks for your response , we tried to use AWExporterParameter.PROCESS_SUBREPORT_HEADER_AS_HEADER but it didn’t work.

We have subreports that contains only header that we use it in many reports (+20)
MicrosoftTeams-image (4).png (70.1 KB)

you can find attached an image to explain the situation.

@Mouna87
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSJR-358

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@alexey.noskov

here is a jrpintfile example for your tests if you need to analyze the problem.

jprintfile.zip (2.9 KB)

maybe we should adjust our subreports to fix the issue.

Thanks in advance for your answer

@Mouna87 Thank you for additional information. I have attached jrpintfile to the defect.

Thanks @alexey.noskov
the bug will be treated on the next release ?
or we can have a quick solution for now ?
we re blocked on our side

Hi @Mouna87

I will check your file in test environment and change code of AW for JasperReport for solving problem.
It can take time and you can see the Issue Status down on the page.

If you want quick solution you can change subreport:

  • Take subreports that contains only header content
  • Move header content from <detail> to <pageHeader>
  • Use AWExporterParameter.PROCESS_SUBREPORT_HEADER_AS_HEADER

Thanks @anatoly.sidorenko

We just did as you explained and it works as expected.

2 Likes