jsp 页面生成表 怎么 导出excel 的形式 ?? 急用 啊 谢谢诶 各位 大侠啊 !! 如果 有程序 可以给俺发到[email protected]
解决方案 »
- JavaScript事件驱动中的疑问。。。
- 在服务器端,载入xml,实现导航,在firefox下,无法显示
- 求 js "感应" iframe 的滚动条.在线等!
- javascript 判断 字符串是否存在,并抓取出来?
- 请问javascript中有:闭包,prototype和面向对象是学习重点,还有什么呢?
- 发布extjs +SSH 到apache+tomcat 时,如果使用directengine 会导致程序出错,有没有好方法?
- 高手请进:
- 用win xp的有分挣了 60分
- 如何在网页中实现类似如IE的工具栏中(工具-邮件与新闻-新邮件)的三层或多层目录结构?
- 判断点击元素的索引值,比如jquery的index函数
- 奇怪的style.top设置。
- js能控制页面在新选项卡中打开吗?多谢
<tr>
<td colspan="5" align="center">WEB页面导出为EXCEL文档的方法</td>
</tr>
<tr>
<td>列标题1</td>
<td>列标题2</td>
<td>列标题3</td>
<td>列标题4</td>
<td>列标题5</td>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
<td>ddd</td>
<td>eee</td>
</tr>
<tr>
<td>AAA</td>
<td>BBB</td>
<td>CCC</td>
<td>DDD</td>
<td>EEE</td>
</tr>
<tr>
<td>FFF</td>
<td>GGG</td>
<td>HHH</td>
<td>III</td>
<td>JJJ</td>
</tr>
</table>
<%@ page language="java" pageEncoding="GBK"%>
<%response.setContentType("application/vnd.ms-excel");
response.addHeader("Content-Disposition", "attachment; filename=abc.xls");%>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40"><head>
<meta http-equiv=Content-Type content="text/html; charset=GBK">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Sheet1</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>285</x:DefaultRowHeight>
<x:Selected/>
<x:Panes>
<x:Pane>
<x:Number>3</x:Number>
<x:ActiveRow>2</x:ActiveRow>
<x:ActiveCol>1</x:ActiveCol>
</x:Pane>
</x:Panes>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>9090</x:WindowHeight>
<x:WindowWidth>11715</x:WindowWidth>
<x:WindowTopX>240</x:WindowTopX>
<x:WindowTopY>90</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body>
<table border="1" cellspacing="1" cellpadding="1">
<tr><td colspan="5" align="center">WEB页面导出为EXCEL文档的方法</td></tr>
<tr>
<td>列标题1</td>
<td>列标题2</td>
<td>列标题3</td>
<td>列标题4</td>
<td>列标题5</td>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
<td>ddd</td>
<td>eee</td>
</tr>
<tr>
<td>AAA</td>
<td>BBB</td>
<td>CCC</td>
<td>DDD</td>
<td>EEE</td>
</tr>
<tr>
<td>FFF</td>
<td>GGG</td>
<td>HHH</td>
<td>III</td>
<td>JJJ</td>
</tr>
</table>
</body>
</html>
<%
response.setContentType("application/vnd.ms-excel");
response.addHeader("Content-Disposition", "attachment; filename=abc.xls");
request.setCharacterEncoding("GBK");
String body = request.getParameter("body");
%>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40"><head>
<meta http-equiv=Content-Type content="text/html; charset=GBK">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Sheet1</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>285</x:DefaultRowHeight>
<x:Selected/>
<x:Panes>
<x:Pane>
<x:Number>3</x:Number>
<x:ActiveRow>2</x:ActiveRow>
<x:ActiveCol>1</x:ActiveCol>
</x:Pane>
</x:Panes>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>9090</x:WindowHeight>
<x:WindowWidth>11715</x:WindowWidth>
<x:WindowTopX>240</x:WindowTopX>
<x:WindowTopY>90</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body>
<table border="1" cellspacing="1" cellpadding="1">
<% out.print(body); %>
</table>
</body>
</html>
------------------------test.htm<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=GBK">
</head>
<body>
<form id="frm1" action="DownXLS.jsp" target="_blank" style="margin:0;padding:0;" method="POST">
<input type="hidden" name="body" value="" />
</form>
<script type="text/javascript">
function downXLS() {
// 把表格内容用表单 POST 到 DownXLS.jsp
var tab = document.getElementById("tab1");
var frm = document.getElementById("frm1");
frm.body.value = tab.innerHTML;
frm.submit();
}
</script>
<table id="tab1" border="1" cellspacing="1" cellpadding="1">
<tr><td colspan="5" align="center">WEB页面导出为EXCEL文档的方法 </td></tr>
<tr>
<td>列标题1 </td>
<td>列标题2 </td>
<td>列标题3 </td>
<td>列标题4 </td>
<td>列标题5 </td>
</tr>
<tr>
<td>aaa </td>
<td>bbb </td>
<td>ccc </td>
<td>ddd </td>
<td>eee </td>
</tr>
<tr>
<td>AAA </td>
<td>BBB </td>
<td>CCC </td>
<td>DDD </td>
<td>EEE </td>
</tr>
<tr>
<td>FFF </td>
<td>GGG </td>
<td>HHH </td>
<td>III </td>
<td>JJJ </td>
</tr>
</table>
<input type="button" value="down" onclick="javascript: downXLS();" />
</body>
</html>