日期:2014-05-16  浏览次数:20487 次

用JXL方式JSP导出Excel,前面的0消失问题

?

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

style='mso-number-format:"\@";'?

?


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

?

经同事测试,不是JSP的也可以解决此问题.要在<TD></TD>里加入此句:

?

<TD style='mso-number-format:"\@";'></TD>

?

?

附: execl的所有格式

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)

?


?