pallavig026 Posted October 17, 2018 Share Posted October 17, 2018 Hi,In my project we use jasper report for report generation.. Where 4 reports needs to be changed every month on 14. Is there any technique we can automate this?This is the code snippet we use:<staticText> <reportElement key="staticText-2" mode="Opaque" x="381" y="242" width="79" height="18" forecolor="#000000" backcolor="#FFFFFF" uuid="4ec23e25-c8d9- 4941-bd81-777aff6c08a7"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/> <paragraph lineSpacing="Single"/> </textElement> <text><![CDATA[14.09.2018]]></text> </staticText>Every month we change the date to next month. For examplewe need to change the date from [CDATA[14.09.2018] to [CDATA[14.10.2018] . Basically on 14th of every month we need to change the date to next month.Can you please help how can we automate this. Link to comment Share on other sites More sharing options...
miwagada Posted October 17, 2018 Share Posted October 17, 2018 try this out. :<variable name="cur_date" class="java.lang.String"> <variableExpression><![CDATA["02-09-2019"]]></variableExpression> </variable> <variable name="Variable_1" class="java.lang.String"> <variableExpression><![CDATA[new SimpleDateFormat("dd-MM-yyyy").format(NOW( )).toString()]]></variableExpression> </variable> <variable name="Variable_2" class="java.util.Date"> <variableExpression><![CDATA[NOW()]]></variableExpression> </variable> <background> <band splitType="Stretch"/> </background> <pageFooter> <band height="51" splitType="Stretch"> <textField> <reportElement x="60" y="10" width="100" height="30" uuid="0d31c363-a408-485d-9e99-1bb922846a90"/> <textFieldExpression><![CDATA["Cur Date : "+$V{cur_date}]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="117" splitType="Stretch"> <textField> <reportElement x="170" y="43" width="340" height="30" uuid="cd531e57-7944-4354-af7c-9c37bf897e80"/> <textElement textAlignment="Left" verticalAlignment="Top"/> <textFieldExpression><![CDATA[$V{cur_date}.substring(0,2)!="14"?"14"+$V{cur_date}.substring(2,5)+$V{cur_date}.substring(5,10):$V{cur_date}]]></textFieldExpression> </textField> <textField> <reportElement x="302" y="14" width="100" height="30" uuid="70643b88-d842-4e6f-9746-bc5a613bc84a"/> <textFieldExpression><![CDATA[$V{Variable_2}]]></textFieldExpression> </textField> </band> </summary> Link to comment Share on other sites More sharing options...
pallavig026 Posted October 17, 2018 Author Share Posted October 17, 2018 Hi,Its giving the error :Description Resource Path Location Typecvc-complex-type.2.4.a: Invalid content was found starting with element 'variable'. Im uising Jaspersoft Studio-6.1.0.. Attaching the full jasper report. Can you please help.I have defined the Varibale at the beginning also. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now