jsp导出excel文件并设定单元格格式
2013-07-01 16:15
411 查看
jsp导出excel文件并设定单元格格式
需要注意一下,不要把"\"写成“/”,不然格式会转化失败。
转自:http://www.blogjava.net/lushengdi/archive/2009/08/10/290494.html
<%@ page contentType="application/msexcel" %> <!-- 以上这行设定本网页为excel格式的网页 --> <% response.setHeader("Content-disposition","inline; filename=test1.xls"); //以上这行设定传送到前端浏览器时的档名为test1.xls //就是靠这一行,让前端浏览器以为接收到一个excel档 %> <html> <head> <title>Excel档案呈现方式</title> <style> .xlsText{mso-number-format:"\@";} </style> </head> <body> <table border="1" width="100%"> <tr> <td>姓名</td><td>身份证字号</td><td>生日</td> </tr> <tr> <td>李玟</td><td class="xlsText">00111111111</td><td>1900/11/12</td> </tr> <tr> <td>梁静如</td><td>00222222222</td><td>1923/10/1</td> </tr> <tr> <td>张惠妹</td><td>00333333333</td><td>1934/12/18</td> </tr> </table> </body> </html>
添加一下CSS样式: 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)
需要注意一下,不要把"\"写成“/”,不然格式会转化失败。
转自:http://www.blogjava.net/lushengdi/archive/2009/08/10/290494.html
相关文章推荐
- jsp导出excel文件并设定单元格格式
- jsp导出excel文件并设定单元格格式
- jsp导出excel文件并设定单元格格式
- jsp导出excel文件并设定单元格格式
- jsp导出excel文件并设定单元格格式
- 在Java中导出word、excel格式文件时JSP页面头的设置
- jsp导出excel身份证过长导致显示不正常自定义单元格格式解决方法
- jsp 导出excel的格式有关问题
- jsp按格式导出doc文件
- 收藏--页面导出为Excel文件中时间格式的问题
- 关于weblogic下用jxl.jar包用的excel导出报,文件错误,某些数字格式可能丢失
- C#导出Excel,并且设置Excel单元格格式,合并单元格
- php 数据库中的回车换行导出excel文件时切换单元格的解决办法
- ASP.NET导出Excel或Word文件格式
- Java导出Excel 单元格格式设置
- datatables插件导出excel【指定excel单元格格式,禁止用科学计数法显示】
- java web中将数据导出为Excel格式文件代码片段
- NPOI导出Excel文件,对单元格的一些设置
- jsp中使用EXCEL组件将表格导出为EXCEL文件
- asp.net中通过html格式导出excel文件