<Style>
. Xlstext {MSO-style-parent: style0; MSO-number-format: "\ @";}/* set the cell type to text */
</Style>
<%
Response. contenttype = "application/vnd. MS-excel" 'sets the webpage output type to excel.
%>
<Table>
<Tr>
<TD> Field 1 </TD>
<TD> Field 2 </TD>
<TD> Field 3 </TD>
<TD> Field 4 </TD>
</Tr>
<Tr>
<TD class = "xlstext"> <% = value of Field 1%> </TD> <! -- The cell is in text format -->
<TD class = "xlstext"> <% = value of Field 2%> </TD> <! -- The cell is in text format -->
<TD> <% = value of Field 3%> </TD>
<TD> <% = value of field 4%> </TD>
</Tr>
</Table>
MSO-number-format: "0" No Decimals
MSO-number-format: "0 \. 000" 3 Decimals
MSO-number-format: "\#\,\#\# 0 \. 000" comma with 3 Dec
MSO-number-format: "mm \/DD \/YY" date7
MSO-number-format: "Mmmm \ D \, \ YYYY" date9
MSO-number-format: "m \/d \/yy \ H \: mm \ am \/PM" D-T ampm
MSO-number-format: "short date" 01/03/1998
MSO-number-format: "Medium date" 01-Mar-98
MSO-number-format: "d \-Mmm \-YYYY" 01-Mar-1998
MSO-number-format: "Short Time" 5: 16
MSO-number-format: "medium time" 5:16 AM
MSO-number-format: "Long time" 5: 16: 21: 00
MSO-number-format: "percent" percent-two decimals
MSO-number-format: "0%" percent-No Decimals
MSO-number-format: "0 \. e + 00" scientific notation
MSO-number-format: "\ @" Text
MSO-number-format :"\#\??? \/??? "Fractions-up to 3 digits (312/943)
MSO-number-format: "\ 0022 & pound; \ 0022 \#\,#\# 0 \. 00" & pound; 12.76
MSO-number-format: "\#\,\#\# 0 \. 00 _ \; \-\ # \, # \ #0 \. 00 \ "2 decimals, negative numbers in red and signed
(1.56-1.56)
Example:
When <% @ page contenttype = "application/vnd. MS-Excel; charset = UTF-8 "%> when exporting JSP files to excel, if the exported data contains numbers starting with 0, the 0 will be omitted, to keep the first 0, you can add:
Style = 'mso-number-format :"\@";'
In this case, the number with the first digit 0 in the exported table will be retained!