Calculate, first date of the given date , the day of the first date and return 0,1,2,3... for Sun, Mon, Tue,Wed and etc.
JRXML : Copy paste below code in a JRXML file and preview the report.
(Supports in 6.x CE & Pro Studio)
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-05T22:43:54 -->
<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="demo_calendar" columnCount="7" printOrder="Horizontal" pageWidth="1500" pageHeight="612" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="211" leftMargin="11" rightMargin="11" topMargin="10" bottomMargin="10" uuid="32abf871-39b8-4cc7-b03c-d950a55e2bfb">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="ireport.jasperserver.url" value="http://localhost:8081/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.report.resource" value="/Work/EarthlySystem/Reports/CalenderReport_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/Work/EarthlySystem/Reports/CalenderReport"/>
<style name="Style1" forecolor="#050505">
<conditionalStyle>
<conditionExpression><![CDATA[$F{id}.intValue()%7==1]]></conditionExpression>
<style forecolor="#FA0702"/>
</conditionalStyle>
</style>
<parameter name="Date" class="java.util.Date">
<defaultValueExpression><![CDATA[new Date()]]></defaultValueExpression>
</parameter>
<parameter name="FirstDateOfMonth" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(MONTH($P{Date}) + "/1/" + YEAR($P{Date})))]]></defaultValueExpression>
</parameter>
<parameter name="FirstDayOfMonth" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[new SimpleDateFormat("EEE").format(java.util.Date.parse(MONTH($P{Date}) + "/1/" + YEAR($P{Date})))]]></defaultValueExpression>
</parameter>
<parameter name="DayReturnValueString" class="java.lang.String" isForPrompting="false">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA[$P{FirstDayOfMonth}.equals("Sun") ? "0":
$P{FirstDayOfMonth}.equals("Mon") ? "1" :
$P{FirstDayOfMonth}.equals("Tue") ? "2" :
$P{FirstDayOfMonth}.equals("Wed") ? "3" :
$P{FirstDayOfMonth}.equals("Thu") ? "4" :
$P{FirstDayOfMonth}.equals("Fri") ? "5" :
$P{FirstDayOfMonth}.equals("Sat") ? "6" : "100"]]></defaultValueExpression>
</parameter>
<parameter name="DayReturnValueInteger" class="java.lang.Integer" isForPrompting="false">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA[Integer.parseInt($P{DayReturnValueString})]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select 1 as One]]>
</queryString>
<field name="one" class="java.lang.Integer"/>
<title>
<band height="180">
<textField pattern="MMMM d, yyyy">
<reportElement x="330" y="0" width="190" height="30" uuid="21293131-3839-43aa-b449-b19867eee2da"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{Date}]]></textFieldExpression>
</textField>
<staticText>
<reportElement mode="Opaque" x="844" y="30" width="210" height="31" forecolor="#000000" backcolor="#FFFFFF" uuid="81be3ac1-c1c1-4573-86a7-67c891288f1c">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<box>
<pen lineWidth="1.0" lineColor="#B1B5B4"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Thursday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1055" y="30" width="210" height="31" forecolor="#000000" backcolor="#FFFFFF" uuid="9442d83e-3726-4db9-8746-04b2fea1449b">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<box>
<pen lineWidth="1.0" lineColor="#B1B5B4"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Friday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1266" y="30" width="210" height="31" forecolor="#000000" backcolor="#FFFFFF" uuid="edc883b5-0e35-4e17-8a45-56efc9dacf6a">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<box>
<pen lineWidth="1.0" lineColor="#B1B5B4"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Saturday]]></text>
</staticText>
<textField>
<reportElement x="330" y="30" width="190" height="30" uuid="ca304690-d49b-4280-8c75-8fd1451bd59f"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format(java.util.Date.parse(MONTH(NOW( )) + "/1/" + YEAR(NOW())))]]></textFieldExpression>
</textField>
<textField>
<reportElement x="330" y="61" width="190" height="30" uuid="5d27b8b2-76cf-4eed-8486-6644f5a2c77c"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{FirstDateOfMonth}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="330" y="90" width="190" height="30" uuid="66294bd1-0841-4c2a-b33a-928a0cb1aa0a"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{FirstDayOfMonth}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="330" y="120" width="190" height="30" uuid="83fa6364-da26-4578-beaf-58932abc6aab"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{DayReturnValueString}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="330" y="150" width="190" height="30" uuid="e341926d-38a0-40e7-b4a6-9232352a7247"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{DayReturnValueInteger}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="30" width="330" height="30" uuid="132ad66e-8839-4c41-8e00-9d77cf0ad6b8"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["First Date Of Month In TEXT field"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="60" width="330" height="30" uuid="166e5bec-db19-4a56-a335-470008c8094c"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["First Date Of Month from Parameter Calcualtion"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="91" width="330" height="30" uuid="dfd0e3d3-1641-4380-984f-0066d8a9112c"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Day Name of First Date Of Month"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="120" width="330" height="30" uuid="d64905e0-2d87-415f-acab-3747492a2071"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Retruning 0,1,2... for Sun, Mon, Tue, ...."+"as a String"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="150" width="330" height="30" uuid="99f5b0f5-cefb-449b-9edb-e444e4afa5d5"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Retruning 0,1,2... for Sun, Mon, Tue, ...."+"as an Integer"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="330" height="30" uuid="09477045-1a0c-4c25-8776-715036b8c726"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Date Entered"]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
No comments:
Post a Comment