[收藏]ASP输出Excel文本格式确定 | asp设置Excel单元格类型为文本

本文介绍了一种使用JSP导出Excel文件的方法,并特别强调了如何通过设置表格样式来保留数字前导零的问题。


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


         字段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保留啦!

转载于:https://www.cnblogs.com/laoxingxuzhou/archive/2010/12/01/5044072.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值