<%
          response.ContentType="application/vnd.ms-excel"     '设置网页输出类型为:Excel
%>


        
        
        
        


                
                 
        
        

字段1 字段2 字段3 字段4
<%= 字段1的值 %> <%= 字段2的值 %> <%= 字段3的值 %> <%= 字段4的值 %>

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£/0022/#/,/#/#0/.00"
£12.76

mso-number-format:"/#/,/#/#0/.00_ /;/[Red/]/-/#/,/#/#0/.00/ "

2 decimals, negative numbers in red and signed
(1.56 -1.56)

用法举例:

当我们用<%@page contentType="application/vnd.ms-excel; charset=UTF-8"%>的方法导出jsp文件为excel时,如果导出的数据中有数字以0开头,则该0会被省略,为了保留这个处于首位的 0,可以在表格的style中加入:

style='mso-number-format:"/@";'

这样的话,导出的该表格中首位为0的数字就会将该0保留啦!

posted on 2010-12-01 13:28  rickyxing  阅读(634)  评论(0编辑  收藏  举报