jasper-reportsdocxexport-to-word

How to disable "Specify Height" property in docx?


I am using JasperReports 4.6.0 and JDK 1.6 to generate my .docx report.

Jasper generates actually the report by default in a form of a one column table, where every component (e.g. TextField) occupies one row. The problem I am facing in the present situation is that whenever I want to edit my output report and add manually a new line in some textField, I have to widen the height of the given textField by widening the table row (i.e. click and slide).

This seems to be a tedious task to do. So I had a look at the properties of a casual MS Word table and I have noticed a property called "Specify height"

![Example]1

That is enabled by default in my jasper output report. If disabled, one could simple add a CR and all rows beneath would move as well. That being said, I want to disable this property in my jasper (whether from java or jrxml).

Here's my jrxml :

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="profile_report" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="0" bottomMargin="0" uuid="40a9d14e-f38a-4588-b1d3-216588ae5e9a">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>  
    <style name="backgroundStyle" mode="Opaque" backcolor="#009AB7" forecolor="#FFFFFF"/>   


    <parameter name="experience" class="java.lang.String"/>

    <parameter name="skills" class="java.lang.String"/>
    <parameter name="skillsDataSource" class="java.util.List"/>
    <parameter name="subreport_mainCat_parameter" class="net.sf.jasperreports.engine.JasperReport"/>
    <parameter name="subreport_subCat_parameter" class="net.sf.jasperreports.engine.JasperReport"/>
    <parameter name="subreport_skill_parameter" class="net.sf.jasperreports.engine.JasperReport"/>

    <detail>
        <band height="50">

            <textField isStretchWithOverflow="true">
                <reportElement positionType = "Float" x="50" y="0" width="455" height="20" uuid="ce308940-e950-4d33-97b9-47d6fb10ee08"/>
                <textElement>
                    <font size="10" />
                    <paragraph lineSpacingSize="0"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{experience}]]></textFieldExpression>
            </textField>

            <textField> 
                <reportElement positionType = "Float" style="backgroundStyle" x="50" y="22" width="455" height="20" uuid="ce308940-e950-4d33-97b9-47d6fb11ee08"/>
                <textElement>
                    <font fontName="Calibri"  size="12" />
                    <paragraph lineSpacingSize="0"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{skills}]]></textFieldExpression>
            </textField>

            <subreport>
                <reportElement positionType = "Float" x = "50" y = "44" width = "455" height = "3" isRemoveLineWhenBlank = "true" backcolor = "#99ccff"/>
                <subreportParameter name="subreport_subCat_parameter">
                    <subreportParameterExpression><![CDATA[$P{subreport_subCat_parameter}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="subreport_skill_parameter">
                    <subreportParameterExpression><![CDATA[$P{subreport_skill_parameter}]]></subreportParameterExpression>
                </subreportParameter>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{skillsDataSource})]]></dataSourceExpression>
                <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{subreport_mainCat_parameter}]]></subreportExpression>
            </subreport>
        </band>
    </detail>

</jasperReport>

Solution

  • To disable “Specify Height” property, you should set property

    net.sf.jasperreports.export.docx.flexible.row.height=true, default it is false

    jrxml

    <?xml version="1.0" encoding="UTF-8"?>
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="afeb1e80-f428-4ec0-930e-64d32f4d7e57">
        <property name="net.sf.jasperreports.export.docx.flexible.row.height" value="true"/>
    ....
    </jasperReport>
    

    IDE (JasperSoft Studio)

    Select report in in outline, in properties switch to tab advanced, click the button that appear when you select the properties property

    Finding the properties

    This opens a dialog, press "add", and insert the property

    Add property