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

如何将表格保存为excel?谢谢各位大哥
function dexport() //导出 

var strnopage=document.all("txt_nopage").value; 
var strname=document.all("txtkeyword").value; 
var cc= index.BindGrid1(strnopage,strname).value; 
alert(""+cc+"");//弹出的对话框是一个表格代码 
return false; 

我在后台中使用下面的方法,我想用前台如何做,谢谢各位大侠? 
string Name="采购订单表"; 
Response.AppendHeader("Content-Disposition","attachment;filename="+System.Web.HttpUtility.UrlEncode(Name,System.Text.Encoding.UTF8)+".xls"); 
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8"); 
Response.Charset="";  
this.EnableViewState=false; 
......

------解决方案--------------------
http://topic.csdn.net/u/20070906/23/cc2306e8-9917-46ac-951d-ddbb55646033.html
------解决方案--------------------
http://topic.csdn.net/u/20070909/20/91fc022b-25b5-4581-aba2-da958cf242dd.html
------解决方案--------------------
http://ironurbane.bokee.com/viewdiary.16844986.html  你可以看看 自己以前这弄的,
------解决方案--------------------
<%@ page language="java" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%response.setContentType("application/msexcel;charset=GB2312");
response.setHeader("Content-disposition","inline; filename=test1.xls");%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> 
<title>测试页面</title> 
</head> 
<body> 
<table border="1" id="table1">
<tr>
<td>100</td>
<td>110</td>
<td>111</td>
</tr>
<tr>
<td>200</td>
<td>220</td>
<td>222</td>
</tr>
<tr>
<td>300</td>
<td>330</td>
<td>333</td>
</tr>
<tr>
<td>400</td>
<td>440</td>
<td>444</td>
</tr>
</table>
</body>
</html>