I. Overview
1) Expected effect
Select month in the date widget to view the days and weeks of the month. As shown below:
2) Implementation roadmap
Use the RANGE formula and DAYSOFMONTH to get the number of days in the month and concatenate the values of the widget.
Use the SWITCH and WEEKDAY formulas to get the day of the week.
II. Example
1) Formula introduction
Formula | Notes |
---|---|
DAYSOFMONTH($time+"01") | Gets the number of days in the month of the date widget |
RANGE(1, DAYSOFMONTH($time + "-01")) | Gets the date from the first day to the last day of the date |
$time + "-" + FORMAT(A1, "#00") | Concatenate the days and dates obtained earlier |
SWITCH(WEEKDAY($time + "-" + FORMAT(A1, "#00")), "1", "Monday", "2", "Tuesday", "3", "Wednesday", "4", "Thursday", "5", "Friday", "6", "Saturday", "0", "Sunday") | Use WEEKDAY formula to get the day of the current week, and use SWITCH formula to display Chinese characters |
2) Insertion formula
In the FineReport Designer, click File >New General Report;
Right-click cell A1 and select Cell Element >Insert Formula.The formula is:RANGE(1, DAYSOFMONTH($time + "-01"))
Right-click on cell A2 and select Cell Element >Insert Formula.The formula is: $time + "-" + FORMAT(A1, "#00")。
Right-click A3 cell and select Cell Element >Insert Formula. which is: SWITCH (WEEKDAY ($time + "-" + FORMAT (A1, "# 00")), "1", "Monday", "2", "Tuesday", "3", "on Wednesday", "4", "Thursday", "5", "Friday", "6", "Saturday", "0", "Sunday ").
Center the cell content, and enclose the three cells with border (border custom).
The following figure shows the steps for cell A1, and the same steps for cell A2 and A3. As shown below:
3) Cell attributes
The contents of A1, A2 and A3 cells are centered with a border (custom border).
Left-click on cell A1 and select Cell Attributes >Expand in the right property panel.Select Horizontal expansion direction. As shown below:
4) Date widget
Go to the parameter panel of the template and drag "Date widget" and "Query Button" into the parameter panel.
The date widget name is time, the value is 2019/10/01, and the format is YYYY-MM. As shown below:
5. Effect preview
Save the template and click Date Entry Preview the effect as described in Section I.
Note: This method does not support mobile terminals.
Note: No characters can be placed under the table header, otherwise there will be wrong lines in pagination.
III. Download the template
For a completed template, see: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Parameter\Query_the_day_and_week_of_ a_month_based_on_the_date_widget.cpt
Click to download the template:
Query_the_day_and_week_of_ a_month_based_on_the_date_widget.cpt