I. Overview
1. Application scenarios
Realize the calendar of each month, and you can switch between the previous and next months by clicking.
2. Realization idea
1) Get the first day of the week where the first day of the current month is located, get the last day of the week where the last day of the current month is located, and use the range() formula to generate all dates between these two dates.
2) Realize month switching through dynamic parameters.
II. Example
1. Design report
1) The report style is designed as follows:
A1 customize parent cell to A2.
Fill in cell A2 with the formula: [1,2,3,4,5,6,0]
Note: Some systems use the dateinweek() function to get the first day of Sunday. At this time, just change the formula of cell A2 to [0,1,2,3,4,5,6].
Fill in cell A3 with the formula: GREPARRAY(range(dateinweek(dateinmonth($rq, 1), 1), dateinweek(dateinmonth($rq, -1), -1)), weekday(item) = A2)
Cell A2 is set to expand horizontally, and cell A3 is set to expand vertically.
2) Set three conditional formatting in cell A1:
When A2=4, the new value is the formula type: left($rq,7)
When A2=1, the new value is the string <, use the Hyperlink> Dynamic Parameters, the parameter is rq, and the value is the formula type: monthdelta($rq,-1)
When A2=0, the new value is string>, use Hyperlink>Dynamic Parameters, the parameter is rq, and the value is the formula type: monthdelta($rq,1)
3) Set Display>Data Dictionary>Custom in A2.
4) Set Display>Formula Form in A3, the formula is: day($$$)
5) Set two Conditional Formatting> Color in cell A3.
When the date is a weekend, the font is red.
When the date does not belong to the current month, the font is gray.
6) Set Template> Template Parameters.
The parameter name is rq and the value is the formula: today()
2. Effect preview
Save the template, click Pagination Preview, the effect is as I.1 above.
Note: Mobile terminal is supported.
III. Download template
Refer to completed template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\BasicApplication\Dynamic_calendar.cpt
Click to download: