search cancel

additional line exporting in CSV the Current Ports Detail: Group report

book

Article ID: 214985

calendar_today

Updated On:

Products

CA Spectrum

Issue/Introduction

Running the Current Ports Detail: Group report and then exporting it in a CSV file, in the output you could see an additional line eg.

 

Is there a way to remove it?

 

Cause

The latest column (Is port available)  is duplicated when value is Yes.

The reason is in the Report definition:
 
 <textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="DetailText" positionType="Float" x="870" y="0" width="90" height="30" forecolor="#073BF7" uuid="51a641ad-ed5d-4e43-9498-0802e398a044">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{v_available}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="DetailText" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="890" y="0" width="60" height="30" forecolor="#FFFFFF" backcolor="#009900" uuid="a40b0579-ed69-4502-bdbe-cd9d2f75ace1">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<printWhenExpression><![CDATA[$V{v_available}.equalsIgnoreCase("yes")]]></printWhenExpression>
</reportElement>
<box leftPadding="10" rightPadding="10"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{v_available}]]></textFieldExpression>
</textField>
 
As you can see in the xml above, value of $V{v_available} is printed once when its value is no (only first block applies), but twice when its value is yes (first and second blocks).
 
Second block is defined so that, when printed in the browser, it overlaps the first block but the same mechanism does not work when we export it.

Environment

Release : 10.4.1 Jaspersoft 6.4.3

Component : Spectrum Core / SpectroSERVER

Resolution

The solution is to replace that text by this one (in green what I added, in grey what I commented out).
 
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="DetailText" positionType="Float" x="870" y="0" width="90" height="30" forecolor="#073BF7" uuid="51a641ad-ed5d-4e43-9498-0802e398a044">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<printWhenExpression><![CDATA[$V{v_available}.equalsIgnoreCase("no")]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{v_available}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<!--reportElement style="DetailText" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="890" y="0" width="60" height="30" forecolor="#FFFFFF" backcolor="#009900" uuid="a40b0579-ed69-4502-bdbe-cd9d2f75ace1"-->
<reportElement style="DetailText" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="870" y="0" width="90" height="30" forecolor="#FFFFFF" backcolor="#009900" uuid="a40b0579-ed69-4502-bdbe-cd9d2f75ace1">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<printWhenExpression><![CDATA[$V{v_available}.equalsIgnoreCase("yes")]]></printWhenExpression>
</reportElement>
<box leftPadding="10" rightPadding="10"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{v_available}]]></textFieldExpression>
</textField>
 
To modify this xml:
 
1) Go to View > Repository
 
 
2) Search the report, select Export and accept the default options
 
 
3) Unzip the export.zip file downloaded and search for this file export/resources/public/ca/spectrum/reports/assets/group/Current_Port_Details_Group_files/Current_Ports_Detail_Group_SubReport.jrxml.data
 
Note: the zip file acts as a backup in case something goes wrong. Do not remove it.
 
4) Copy that file to your Desktop and rename it to Current_Ports_Detail_Group_SubReport.jrxml
 
5) Edit it and change the lines commented above
 
6) Save it
 
7) Search the report again in the Repository and select Edit
 
 
8) Click on Controls & Resources and click on the Remove link corresponding to Current_Ports_Detail_Group_SubReport.jrxml
 
 
9) Once removed, click on Add Resource, select the Current_Ports_Detail_Group_SubReport.jrxml file in your desktop (the one you modified) and click Next
 
 
10) Set the Name and ResourceID fields as showed, and click Next.
Specify the file extension ".jrxml" in Name and ResourceID fields.
 

 
11) Check you resource is listed again, and click Submit
 
Now try to run the report again and export it to CSV or Excel to confirm that rows with value Is Port Available? Yes only shows one column.

Attachments