给出解决方案的给200分有没有人知道怎样把查询出来的所有记录导出成EXCLE表的文件呢?

有没有人知道怎样把查询出来的所有记录导出成EXCLE表的文件呢?给出解决方案的给200分。
---------------------------------------------------------------

up
---------------------------------------------------------------

一个例子:

这个是生成电子表格的

1<html>
2<head>
3<title>从数据库生成电子表格文档</title>
4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
5</head>
6<body bgcolor="#FFFFFF" text="#000000">   
7  
8  
9注意:本生成系统使用office自带的owc组件,服务器上必须安装office   

'选出记录集
dim rs,sql
set rs=server.createobject("adodb.recordset")
sql="select * from b_hn_sgbb"
rs.open sql,cn,1,3

dim rstCount,rstField
rstCount=rs.recordcount'记录行数
rstField=rs.fields.count'记录列数

dim oExcel,sCellValue,Path
Set oExcel = Server.CreateObject("OWC.Spreadsheet")

dim Line,Column
Line=1

'写入列名
For Column=0 to rstField-1
sCellValue=rs.fields(Column).name'列名
sCellValue=sCellValue&amp;""
oExcel.Cells(Line,Column+1)= sCellValue '第一行的第几列,列是循环的,行不变。
Next

'写入记录,从第二行开始先行后列的写入表中
For Line=2 to rstcount+1
For Column=0 to rstField-1
sCellValue=rs.fields(Column)
sCellValue=sCellValue&amp;""
oExcel.Cells(Line,Column+1)= sCellValue
Next
rs.movenext
Next
'这行不知道干什么
For Column = 1 to rstField
oExcel.Columns(Column).AutoFitColumns
Next

'设置Excel表里的字体
Column = 1
Do While Column &lt;= rstField
oExcel.Cells(1, Column).Font.Bold = True
oExcel.Cells(1, Column).Font.Italic = False
oExcel.Cells(1, Column).Font.Size = 16
Column = Column + 1
Loop

'输出该表
Path=Server.MapPath("Caseinfo.xls")
oExcel.ActiveSheet.Export Path, 0

1  
2
3   
4<a href="Caseinfo.xls" target="_blank">查看生成的电子表格</a>
5</body>
6</html>

---------------------------------------------------------------

查询出来的记录和数据库中所有的记录区别不大

在影子的第一个例子中把
sql="select * from b_hn_sgbb"
改成你要的查询条件
sql="select * from b_hn_sgbb where 。。。"
就可以了
---------------------------------------------------------------

llg518cn(想休息不能休息)
跟我抢分,没门,我有现存的,我都在公司使用中
---------------------------------------------------------------

使用例子

1<script src="Convertor.js"></script>
 1<body onload="exp()">
 2<xml id="flashData" src="http://www.chinatools.biz:9009/flashbook/result.xml"></xml>
 3<table datasrc="#flashData" id="data">
 4<thead>
 5<tr>
 6<th>±êÌâ</th>
 7<th>×÷Õß</th>
 8<th>ʱ¼ä</th>
 9</tr>
10</thead>
11<tbody datafld="dataroot">
12<tr>
13<td><div datafld="topic"></div></td>
14<td><div datafld="UserName"></div></td>
15<td><div datafld="dateandtime"></div></td>
16</tr>
17</tbody>
18</table>
19<script>   
20function exp()   
21{   
22var tmp = new Convertor();   
23tmp.HTMLData = document.all.tags("table")[0];   
24tmp.ExpToWord();   
25}   
26</script>
27</body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus