Ⅰ jsp頁面上 用表格顯示的資料庫里的數據如何導出excel有例子木有 求高手
<%@pagecontentType="application/msexcel"%>
<!--
以上這行設定本網頁為excel格式的網頁-->
<%
response.setHeader("Content-disposition","inline;filename=test1.xls");
//以上這行設定傳送到前端瀏覽器時的檔名為test1.xls
//就是靠這一行,讓前端瀏覽器以為接收到一個excel檔
%>
<html>
<head>
<title>Excel檔案呈現方式</title>
</head>
<body>
<tableborder="1"width="100%">
<tr>
<td>姓名</td><td>身份證字型大小</td><td>生日</td>
</tr>
<tr>
<td>李玟</td><td>N111111111</td><td>1900/11/12</td>
</tr>
<tr>
<td>梁靜如</td><td>N222222222</td><td>1923/10/1</td>
</tr>
<tr>
<td>張惠妹</td><td>N333333333</td><td>1934/12/18</td>
</tr>
</table>
</body>
</html>
最簡單的。
Ⅱ 網頁上的數據怎麼向Excel導出
這個是我用的時候查到的代碼,我放到jsp頁面了,你看一下,挺好懂的!
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'testTable.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function table2xls()
{ //重寫String的Trim()方法
function String.prototype.Trim() {
return this.replace(/(^\s*)|(\s*$)/g,"");
}
try
{
var e=document.getElementById("myTable");
var s="";
for(var j=0;j<e.rows.length;j++)
{
if(e.rows[0].cells[0].innerText.Trim()=="")
{
for(var i=1;i<e.rows[j].cells.length;i++)
s+=e.rows[j].cells[i].innerText.Trim()+"\t";
}
else
{
for(var i=0;i<e.rows[j].cells.length;i++)
s+=e.rows[j].cells[i].innerText.Trim()+"\t";
}
s+="\r\n";
}
//var xlsWindow =window.open("","_blank","width=100,height=100");
// xlsWindow.document.write(s);
// xlsWindow.document.close();
//xlsWindow.document.execCommand('Saveas',true,'%homeDrive%\\Data.xls')
//xlsWindow.close();
document.execCommand('Saveas',true,'%homeDrive%\\Data.xls');
}catch(e){}
}
</script>
</head>
<body>
<table name="myTable" id="myTable">
<tr>
<td>12</td>
<td>aa</td>
</tr>
<tr>
<td>ww
</td>
<td>bb</td>
</tr>
</table>
<input type="button" value="導出到Excel" onclick="table2xls();">
</body>
</html>
Ⅲ 怎樣復制(導出)網頁資料庫中的數據
網頁形式的沒有這個功能就沒辦法,直接管理資料庫
Ⅳ 怎麼把在html頁面通過後台導出資料庫的內容
將你要保存的HTML格式的內容入到一個div中,並給div一個ID,指定runat="server",獲取div的ID中的內容即可。例:內容一內容二內容三1.用InnerHtml獲取或設置指定HTML伺服器控制項的開始標記與結束標記之間的內容:stringhtmlvalue=divvalue.InnerHtml.ToString();2.用InnerText獲取或設置指定HTML伺服器控制項的開始標記與結束標記之間的文本:stringhtmlvalue=divvalue.InnerText.ToString();
Ⅳ 怎樣將從網站後台的資料庫中導出數據
''利用ASP生成EXECL文檔
'=================================================
set conn=server.createobject("adodb.connection")
conn.open application("connstring")
set rs=server.createobject("Adodb.recordset")
sql="select * from xxloginteachers order by jsid desc"
rs.open sql,conn
do while not rs.eof
msg=msg & rs("jsid") & chr(9) & rs("jsxm") & vbcrlf
rs.movenext
loop
set f=server.createobject("scripting.filesystemobject")
set myfile=f.createtextfile("d:\xmllover.xls",true)
myfile.close
'已生成xmllover.xls!!!!