When weWebData Import on the pageExcelSometimes our data needs to be presented in a specific format.CellAdd some style specifications.
First, let's take a look Excel Slave Web Principle of export on the page. When we send the data to the client, we want the clientProgram(Browser) Excel To read it Mime Type: Application/vnd. MS-Excel , When Excel When reading a file Cell The format Cell If there is no specified format Excel Will be displayed in the default format Cell . This provides us with space for custom data formats. Of course, we must use Excel Supported formats. Common formats are listed below:
1)Text:Vnd. ms-excel.numberformat :@
2) date: vnd. ms-excel.numberformat: yyyy/mm/DD & lt;/span & gt; & lt;/P & gt;
3) Number: vnd. ms-excel.numberformat :#,# 0.00
4) currency: vnd. ms-excel.numberformat : ¥ #,## 0.00
5) Percentage: vnd. ms-excel.numberformat : # 0.00%
You can also customize these formats. For example, you can define the year and month as follows:YY-mmAnd so on. How can I add these formatsCellMedium? It is very simple. We only need to add the style to the corresponding tag pair (that is, to close the tag. For example<TD> </TD>, To the tag pair<TD> </TD>Add a style as follows:
< TD Style =" Vnd. ms-excel.numberformat :@" > 410522198402161833 </ TD >
Similarly, we can also<Div> </div>To add a style, you can also<Tr> </tr>,<Table> </table>Adding a style will introduce a problem. Do you notice this? First look at the followingCode:
< Table Style = 'Vnd. ms-excel.numberformat: #,## 0.00' >
< Tr >
< TD > 542 </ TD >
< TD Style = 'Vnd. ms-excel.numberformat: # 0.00%' > 0.25 </ TD >
</ Tr >
</ Table >
Yes. When we add a style to both the parent tag pair and the Child tag pair, which style will the data be presented in? After testing, it will be presented in the style closest to the data, which is also in line with our wishes (it seems that it is also in line with the saying that the county officials are not as competent as they are now ). In this way, we can change the data inExcel(You can add these style specifications on the front-end page or give the corresponding controls in the background code, such:DataGridAnd so on ). If your application is relatively simple, it is enough to meet your needs. However, if your applications are complex, you can also use different data presentation methods. Next, let's look at an application that is a little more complex.
For example, if your data is to be presented to users in different countries and regions, the data format will be different. How can we solve this problem? Of course, you can process these data manually, but this is not the best method, because if we add users from other countries or regions, then we need to process all the data in the format requested by the customer. When the data volume is large, this is undoubtedly a heavy and boring job. So how should we solve such problems? Next, let me share my opinion: extract the formatted Information to XML File, when the program is running, it reads different formatting information according to different customers, and then dynamically adds the formatting information to our data. In this way, when we add users in other countries or regions, we only need to add one more XML File to write the corresponding formatting information to this XML File, and then when users in this country or region view it, they can read the corresponding formatted Information and apply it to the data.
The above example is a sudden thought of. I believe that multinational corporations will encounter similar problems. The solution is just to provide you with an idea, hoping that the results will be helpful.