Jsp exports an excel file and sets the cell format

Source: Internet
Author: User
<% @ Page contentType = "application/msexcel" %>
<! -- In the preceding line, set this webpage to an excel webpage -->
<%
Response. setHeader ("Content-disposition", "inline; filename=test1.xls ");
// Set the file name test1.xls to be transferred to the browser.
// This line enables the browser to receive an excel file.
%>
<Html>
<Head>
<Title> Excel file presentation mode </title>
<Style>
. XlsText {mso-number-format :"\@";}
</Style>
  
</Head>
<Body>
<Table border = "1" width = "100%">
<Tr>
<Td> name </td> <td> ID card size </td> <td> birthday </td>
</Tr>
<Tr>
<Td> Li Yun </td> <td class = "xlsText"> 00111111111 </td> <td> 1900/11/12 </td>
</Tr>
<Tr>
<Td> Liang jingru </td> <td> 00222222222 </td>
</Tr>
<Tr>
<Td> Zhang huimei </td> <td> 00333333333 </td>
</Tr>
</Table>
</Body>
</Html>
If the cell display format is not set, the number does not display the previous 0 by default. For example, "001" is displayed as 1, and the cell display format can be set as style, the preceding 0 is displayed.
Other formats are set as follows:
  
  
Styling Excel cells with mso-number-format
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 _ \; \ [Red \] \-\#\, \#\# 0 \. 00 \ "2 decimals, negative numbers in red and signed
(1.56-1.56)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.