How to group properly excel data source with rowspan? - excel

From my understanding, <groupExpression> tag will be the one that decides whether a new group will be created or not, if there's a change to the element inside <groupExpression>, a new group will be created.
I want my report to look similar to my Excel data source (refer below) hence I want to group the ID and Name in the Excel file. In my jasperReport.jrxml (refer below), my <groupExpression> for Group1 is the ID column of my Excel File. But when I preview the report (refer below), the ID and Name column is not grouped, instead, there's a null string.
How to properly group them and eliminate the null string?
Excel datasource:
jasperReport.jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 -->
<!-- 2016-01-26T15:33:41 -->
<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="FirstJasperReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8b8832df-588e-4202-826e-a6b3efcbd22b">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="ExcelDataBase"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="Name" class="java.lang.String"/>
<field name="Title" class="java.lang.String"/>
<field name="Balance" class="java.lang.Integer"/>
<variable name="Balance1" class="java.lang.Integer" resetType="Group" resetGroup="Group1" calculation="Count">
<variableExpression><![CDATA[$F{Balance}]]></variableExpression>
</variable>
<variable name="Balance2" class="java.lang.Integer" resetType="Group" resetGroup="Group1" calculation="Sum">
<variableExpression><![CDATA[$F{Balance}]]></variableExpression>
</variable>
<group name="Group1">
<groupExpression><![CDATA[$F{ID}]]></groupExpression>
<groupHeader>
<band height="30">
<rectangle>
<reportElement x="0" y="0" width="400" height="30" backcolor="#DEFCF2" uuid="de6c2f8d-afa6-45b4-b40e-574f2e07057e"/>
</rectangle>
<textField>
<reportElement x="0" y="0" width="100" height="30" uuid="c028645d-9b29-42d3-b91e-d47f15a5b44a"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="30" uuid="85d2844f-ef91-47a1-9223-c6943a25fe4d"/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
......
Preview result:
How to make title1 and title2 appear under the group test1, without the null string (similar to the Excel source file)?

The problem is that the excel datasource is passing $F{ID}==null for second record. This generates the null group (as you can see also the name is null).
The easiest way to fix it is to not use rowspan in excel (include all data in the excel sheet).
If this is not possible you need to save the first $F{ID} value and return this if $F{ID}==null
Example
<variable name="First_ID" class="java.lang.Integer" resetType="Group" resetGroup="Group1" calculation="First">
<variableExpression><![CDATA[$F{ID}]]></variableExpression>
</variable>
In group return variable $V{First_ID} if $F{ID}==null
<group name="Group1">
<groupExpression><![CDATA[$F{ID}==null?$V{First_ID}:$F{ID}]]></groupExpression>
... your groupHeader ....
</group>

Related

Pagination adds an extra blank page at the end

Given the footer of my report :
<pageFooter>
<band height="51" splitType="Stretch">
<textField isStretchWithOverflow="true">
<reportElement positionType = "Float" x="485" y="1" width="55" height="50" uuid="7786fb05-689a-4b6a-915a-a7bcf3abad95"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Calibri" size="10" />
<paragraph lineSpacingSize="0"/>
</textElement>
<textFieldExpression><![CDATA[" - "]]> + $V{PAGE_NUMBER} + <![CDATA[" - "]]></textFieldExpression>
</textField>
</band>
</pageFooter>
My report adds an extra blank page without page number at the end of the report unlike the previous report pages each of which has a page number. When I have tried to remove the pagination and use a staticText component as my footer, the extra blank page is gone.
How could one solve this problem please?

JasperReport: sum fields disappear after xls sorting

I have such xls file generated by jasper:
sum fields has following jrxml properties:
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="1050" y="13" width="90" height="11" isPrintWhenDetailOverflows="true" uuid="a41d8696-c8a2-43bc-a41c-1bfe5499d3d4"/>
<textElement textAlignment="Right">
<font size="8" isBold="true"/>
<paragraph lineSpacing="1_1_2"/>
</textElement>
<textFieldExpression>##my_experssion##</textFieldExpression>
</textField>
After I sort by column I sum fields disappear
Is there any simple way to fix this?

FetchXML View to Include Attributes from Nested Link-Entity

I would like to have a view that show attributes from 3 entities:
Statistics has a lookup to Account and Account has a lookup to Address.
The view is on Statistics and I want attributes from all 3 entities; is this even possible?
The problem is with the GridXML.
I want to include the attribute wl_city in the GridXML.
This is the FetchXML with link-entities:
<fetchxml>
<fetch version="1.0" output-format="xml-platform" mapping="logical">
<entity name="sb_statistics">
<order attribute="sb_amount" descending="false" />
<!-- It is easy to get these into the GridXML -->
<attribute name="sb_debtor" />
<attribute name="sb_date" />
<attribute name="sb_amount" />
<link-entity name="account" from="accountid" to="sb_debtor"
alias="relatedAccount" link-type="outer">
<!-- It is possible to get this into the GridXML
by using the link-entity alias: relatedAccount.wl_towncity -->
<attribute name="wl_towncity" />
<link-entity name="wl_postalcode" from="wl_postalcodeid"
to="wl_postaltowncity" alias="relatedAddress" link-type="outer">
<!-- I have trouble getting this attribute into the GridXML -->
<attribute name="wl_city" />
</link-entity>
</link-entity>
<attribute name="sb_statisticsid" />
</entity>
</fetch>
</fetchxml>
When I change the GridXML as below this error is displayed when the view is opened:
"To use this saved query, you must remove criteria and columns that refer to deleted or non-searchable items"
<layoutxml>
<grid name="resultset" object="10008" jump="sb_name" select="1" preview="1"
icon="1">
<row name="result" id="sb_statisticsid" multiobjectidfield="1">
<cell name="sb_amount" width="100" />
<cell name="sb_date" width="100" />
<cell name="sb_debtor" width="100" />
<cell name="relatedAccount.relatedAddress.wl_city" width="100" />
</row>
</grid>
</layoutxml>
The below GridXML shows this error when the view is opened:
"Unexpected Error An error has occured".
<layoutxml>
<grid name="resultset" object="10008" jump="sb_name" select="1" preview="1"
icon="1">
<row name="result" id="sb_statisticsid" multiobjectidfield="1">
<cell name="sb_amount" width="100" />
<cell name="sb_date" width="100" />
<cell name="sb_debtor" width="100" />
<cell name="relatedAddress.wl_city" width="100" />
</row>
</grid>
</layoutxml>
The GridXML below results in this error being shown when the view is opened:
"To use this saved view, you must remove criteria and columns that refer to deleted or non-searchable columns".
<layoutxml>
<grid name="resultset" object="10008" jump="sb_name" select="1" preview="1"
icon="1">
<row name="result" id="sb_statisticsid" multiobjectidfield="1">
<cell name="sb_amount" width="100" />
<cell name="sb_date" width="100" />
<cell name="sb_debtor" width="100" />
<cell name="wl_city" width="100" />
</row>
</grid>
</layoutxml>
This saved query works, but it only includes attributes from the primary entity and the first link-entity.
<savedquery>
<IsCustomizable>1</IsCustomizable>
<CanBeDeleted>0</CanBeDeleted>
<isquickfindquery>0</isquickfindquery>
<isprivate>0</isprivate>
<isdefault>0</isdefault>
<returnedtypecode>10008</returnedtypecode>
<savedqueryid>{df101ac4-2e4d-e311-9377-005056bd0001}</savedqueryid>
<layoutxml>
<grid name="resultset" object="10008" jump="sb_name" select="1" preview="1"
icon="1">
<row name="result" id="sb_statisticsid" multiobjectidfield="1">
<cell name="sb_amount" width="100" />
<cell name="sb_date" width="100" />
<cell name="sb_debtor" width="100" />
<cell name="relatedAccount.wl_city" width="100" />
</row>
</grid>
</layoutxml>
<querytype>0</querytype>
<fetchxml>
<fetch version="1.0" output-format="xml-platform" mapping="logical">
<entity name="sb_statistics">
<order attribute="sb_amount" descending="false" />
<attribute name="sb_debtor" />
<attribute name="sb_date" />
<attribute name="sb_amount" />
<link-entity name="account" from="accountid" to="sb_debtor"
alias="relatedAccount" link-type="outer">
<attribute name="wl_towncity" />
<link-entity name="wl_postalcode" from="wl_postalcodeid"
to="wl_postaltowncity" alias="relatedAddress" link-type="outer">
<attribute name="wl_city" />
</link-entity>
</link-entity>
<attribute name="sb_statisticsid" />
</entity>
</fetch>
</fetchxml>
<LocalizedNames>
<LocalizedName description="Statistics and Address" languagecode="1033" />
</LocalizedNames>
</savedquery>
Is GridXML limited to showing only attributes from the primary entity and the first link-entity?
This is not possible, according to the best of my knowledge, but please someone prove me wrong.
A limitation of GridXML appears to be that attributes can only be included that are from the first link-entity, not any nested link-entities.
It should work when using link-type="inner" for nested link.
<entity name="sb_statistics">
...
<link-entity name="account" from="accountid" to="sb_debtor"
alias="relatedAccount" link-type="outer">
<attribute name="wl_towncity" />
<link-entity name="wl_postalcode" from="wl_postalcodeid"
to="wl_postaltowncity" alias="relatedAddress" link-type="inner"> //link-type="inner"
<attribute name="wl_city" />
</link-entity>
</link-entity>
<attribute name="sb_statisticsid" />
</entity>
I have found no evidence that it can be done. With or without link-type='inner' the designer (in 2013) says, "The relatedAddress.wl_city column is no longer a valid column because it has been deleted as a column option. You need to remove this column and, if you want, add a different one."
It does NOT need multiple dereferrences, nor does that work. If you dump the keyValuePairs of the AttributeCollection returned by the fetch, you will see the key is relatedAddress.w1_city -- not its parent nor the combination.
Like the UI, it just appears the layout is limited to only root and children, no grandchildren nor further descendants.
I think it's a little late to answer this question, but maybe someone come to this post and find it helpful.
first thing you should know is that, fetchxml will return only column that are not null, so if you are querying a column that there is no data in that, then fetchxml automatically remove it from result set.
second thing is, if you have different table with different relationship, then alias name will be added to the column name, so in your case relatedAccount.wl_towncity and relatedAddress.wl_city is correct and not relatedAccount.relatedAddress.wl_city. in your example, you put alias name after each other that is not correct.
third thing that you should know is that when a nested result will return, the type is object, but original type AliasedValue , so first you have to cast the object to AliasedValue. then it become ready to cast it to OptionSetValue. after that you have to look for .Value that has the result of what you want
I made it work like this: I still have an issue with unresolved columnheaders.
<fetch distinct='true'>
<entity name='rdiac_riskobject'>
<attribute name='rdiac_riskobjectid' />
<attribute name='rdiac_name' />
<attribute name='rdiac_riskobjectproduct' />
<link-entity name='rdiac_riskobject_rdiac_propertydetail' from='rdiac_riskobjectid' to='rdiac_riskobjectid' intersect='true'>
<link-entity name='rdiac_propertydetail' alias='pd1' from='rdiac_propertydetailid' to='rdiac_propertydetailid'>
<attribute name='rdiac_valuestring' />
<link-entity name='rdiac_propertysvconfig' from='rdiac_property' to='rdiac_propertyid'>
<filter>
<condition attribute='rdiac_svfield' operator='eq' value='100000000'/>
</filter>
</link-entity>
</link-entity>
</link-entity>
<link-entity name='rdiac_riskobject_rdiac_propertydetail' from='rdiac_riskobjectid' to='rdiac_riskobjectid' intersect='true'>
<link-entity name='rdiac_propertydetail' alias='pd2' from='rdiac_propertydetailid' to='rdiac_propertydetailid'>
<attribute name='rdiac_valuestring' />
<link-entity name='rdiac_propertysvconfig' from='rdiac_property' to='rdiac_propertyid'>
<filter>
<condition attribute='rdiac_svfield' operator='eq' value='100000001'/>
</filter>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
<grid name='resultset' object='10139' jump='rdiac_riskobjectproduct' select='1' preview='0' icon='1' >
<row name='result' id='rdiac_riskobjectid' >
<cell name='rdiac_riskobjectproduct' width='100' />
<cell name='pd1.rdiac_valuestring' width='200' />
<cell name='pd2.rdiac_valuestring' width='200' />
</row>
</grid>

Excel not well formated in JasperReports

When i export my report to Excel, my cells don't display the whole text if there is more than one row to be displayed in it; it just cuts a part of it and i need to expand the row manually to see the all the data in it
I use the following formatting:
<band height="21">
<staticText>
<reportElement style="pageHeader" mode="Opaque" x="0" y="6" width="88" height="15"/>
<textElement textAlignment="Left">
<font fontName="Cambria" size="10"/>
</textElement>
<text><![CDATA[First Name]]></text>
</staticText>
</band>
<band height="30" splitType="Prevent">
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="88" height="25"/>
<textElement textAlignment="Left">
<font fontName="Cambria" size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{firstName}]]></textFieldExpression>
</textField>
</band>
Is there a xls property i should set?
I solved this problem setting line spacing to double at text field properties menu.
Dosn't look different but shows full text.

create text inside a rectangle using inkscape

I've put some text inside a rectangle using inkscape so the tree is like
<svg:rect><svg:text><svg:tspan>text....
The problem is, I can't see the text. I've tried fiddling with the opacity of the rect to no avail. There should be a way of doing this from the UI?
Edit
example as requested
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="184.25197"
height="262.20471"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
version="1.0"
sodipodi:docname="ex1.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.64"
inkscape:cx="195.9221"
inkscape:cy="335.3072"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="640"
inkscape:window-height="675"
inkscape:window-x="44"
inkscape:window-y="44" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:0.25480766;fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:12.94795799;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect2383"
width="150.87796"
height="84.226181"
x="18.221733"
y="39.557121">
<text
xml:space="preserve"
style="font-size:56.0331955px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="44.815186"
y="114.0088"
id="text2385"
transform="scale(1.0054479,0.9945816)"><tspan
sodipodi:role="line"
id="tspan2387"
x="44.815186"
y="114.0088">text</tspan></text>
</rect>
</g>
</svg>
I'd expect to be able to see this in inkscape.
The workaround is to put text on a layer above the box (the intent is that the box obscures the layers below it) and not try and get clever with nested tags. Shame it doesn't work though.
A rect element can't contain text elements, that's invalid according to the svg specification and will simply be ignored by compliant user agents.
Just put the text after the rect element to have them render on top.

Resources