In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
The content of this article mainly focuses on what is the data display setup strategy stored in the database. The content of the article is clear and well-organized. It is very suitable for beginners to learn and is worth reading. Interested friends can follow the editor to read together. I hope you can get something through this article!
The data stored in the database usually has some code value fields, such as employee number, department code, category ID and so on. If the code value is displayed directly when the report is displayed, the user cannot understand the specific meaning of the code value, so the coded value is required to be converted into a Chinese form that the corresponding user can understand, or the date of birth stored in the database is in date form. The presentation should be converted into the standard form of December 12, 2018. Let's introduce the implementation of this requirement through the actual operation of an example.
First, connect to the demo data source, take a number from the "employees" table to make an employee information table, the report template is as follows:
Click Preview at this time, and the report results are as follows:
Request:
1. Convert the date of birth to the standard yyyy year MM month dd day format
2. Convert gender and academic qualifications into corresponding Chinese forms.
3. Add a currency symbol to the salary
Date format settin
The display format setting is supported in the report cell, and the data is formatted directly. Select the C3 cell, double-click the value property of the display format on the right, and the display format setting dialog box will pop up:
There are various types of formatting. Find the yyyy year MM month dd date in the date category and click OK so that the birth date column can be displayed in the desired format.
The numerical value is converted to Chinese
Next, let's take a look at the gender and education settings. The gender is relatively fixed, which is generally "male" or "female". For this relatively fixed, you can control it in the if function in the display value expression, and write: if (value ()) = = 1, "male", "female") in the display value expression of D4 cell. Value () function is a function that comes with the report, which is used to obtain the real value of the current cell. By judging that the current cell is 1, return the display value of "male", otherwise show "female", note: value () = = 1, the gender field is an integer in the database, so write 1 directly here, if it is a string, you need to write "1", pay attention to the data type, if there are multiple types, you can do if nesting, for details, you can refer to the report function description. For this kind of data is relatively fixed, there is a function can be achieved: map function, can also be written in the D4 cell display value expression: map (list (1jue 2), list ("male", "female")), the first list is listed in the cell list of real values, the second list will show the value of the mapping.
Education cell settings and gender are somewhat similar, both through the display value expression to set, you can use if or map function, but education data will be more, need to write a large number of expressions, and education may change in the database, such as after a period of time will add a new education, but also to modify the report, for this form, the database usually has a Chinese dictionary table. Add a new dataset to the report and take the number from the "DEGREE" table, where the data is as follows:
You can see that the data in ID is the value of the calendar column in the employee table, and the NAME field stores the corresponding Chinese, so that according to the association between the ID and DEGREE fields, you can take out the required Chinese for display. Write: ds2.select (NAME,ID==value (), 1) in the display value expression of the E3 cell, which means that the value of the NAME field whose ID is equal to the current cell value is taken from the ds2 dataset and displayed in the display value. Note that the following 1 is to take out the first record that meets the conditions, if it is satisfied to return directly and no longer judge backward, so in order to improve the efficiency of report calculation, we need to increase the setting of "1". In practice, if the dictionary table and the data table are in the same database, it is recommended to directly extract the Chinese language through a sql through where association, so that it is more efficient when the amount of data is large. If the data comes from different databases, the calculation is slow when the amount of data is large. You can return the two datasets join together to the report that is a dataset through the aggregator This is more efficient, depending on the actual demand.
Currency format
Finally, the salary column can be displayed in the format "¥# 0.00", as shown in the figure:
The final report shows as follows:
In this example, through the use of display format and display value expression to control the display style of the cell, what is changed at this time is the cell display effect, if these cells are referenced in other cells, the reference is the original value of the report cell, if you want to reference the display value, you can use the disp () function.
Display format expression control
At present, the most commonly used display format is to select directly in the display format. In fact, the display format supports expressions to control it. For example, the expression of a cell is: = list (11mem12.5345). This cell is displayed with both floating-point numbers and integers. Many customers want to display integers directly if they are integers, and retain two decimal places if they are floating-point numbers. In this way, the display format expression is used, such as writing: if (value () = = int (value ()), "#", "# 0.00") in the display format expression of the cell to determine whether the value of the cell is an integer. If so, the display format is "#", otherwise the display format is "# 0.00". The effect of the cell preview is as follows:
You can see that the report properties can be dynamically controlled by expressions to achieve a dynamic display effect.
Display values in a special format
Moistening comes with a display format, but some formats may not meet the customer's special needs. For example, the date format of 2018-11-30 needs to be displayed as: 30 Nov. 2018. You can use the display value expression to make special settings. For example, if the B2 cell is a date, write it in the B2 cell display value expression:
String (day (value () + "+ case (month (value ()," 1 ":" Jan. "2": "Feb."; "3": "Mar."; "4": "Apr."; "5": "May."; "6": "Jun."; "7": "Jul."; "8": "Aug."; "9": "Sept."; "10": "Oct."; "11": "Nov." "12": "Dec.") + "+ string (year (value ()
The expression first intercepts the day, month and year in the date through the function, and then converts the month into the desired format and splices it together through the case function, so that the control of the special display format can be realized.
The data can be formatted through the display format, the values in the cell can be changed into other values to display without affecting the real value of the original cell, and the two attributes can be flexibly set by expressions. make the data display settings really flexible to a variety of requirements.
Thank you for your reading. I believe you have some understanding of the problem of "what is the data display strategy stored in the database?" go to practice quickly, if you want to know more related knowledge points, you can pay attention to the website! The editor will continue to bring you better articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.