ation = CreateObject("Excel.application")
xlApplication.Visible = False
xlApplication.Workbooks.Add
Set xlWorksheet = xlApplication.Worksheets(1)
xlWorksheet.Cells(1,1).Value = "Year"
xlWorksheet.Cells(1,1).Interior.ColorIndex = 5
xlWorksheet.Cells(1,2).Value = "Region"
xlWorksheet.Cells(1,2).Interior.ColorIndex = 5
xlWorksheet.Cells(1,3).Value = "Sales"
xlWorksheet.Cells(1,3).Interior.ColorIndex = 5
iRow = 2
If Not oRS.EOF Then
Do Until oRS.EOF
For i = 0 To oRS.fields.Count-1
xlWorksheet.Cells(iRow,i + 1).Value = oRS.fields(i)
xlWorkSheet.Cells(iRow,i + 1).Interior.ColorIndex = 4
Next
iRow = iRow + 1
oRS.MoveNext
Loop
End If
strFile = GenFileName()
xlWorksheet.SaveAs Server.MapPath(".") & "" & strFile & ".xls"
xlApplication.Quit ' Close the Workbook
Set xlWorksheet = Nothing
Set xlApplication = Nothing
Response.Write("Click <A HRef=" & strFile & ".xls>Here</A> to get XLS file")
End Function
</script>
%>
main.htm
<!-- frames -->
<FRAMESET ROWS="20%,*">
<FRAME NAME="Request" SRC="request.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="yes">
<FRAME NAME="Result" SRC="welcome.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="yes">
</FRAMESET>
request.htm
<html>
<head>
<title>Sales Report Demo</title>
</head>
<body>
<DIV ALIGN="center"><FONT SIZE="+1">Sales Reporting</FONT></DIV>
<FORM ACTION="runquery.asp" METHOD="POST" target=Result>
Year <SELECT NAME="Year">
<OPTION VALUE="ALL">ALL</OPTION>
<OPTION VALUE="1995">1995</OPTION>
<OPTION VALUE="1996">1996</OPTION>
<OPTION VALUE="1997">1997</OPTION>
<OPTION VALUE="1998">1998</OPTION>
<OPTION VALUE="1999">1999</OPTION>
</SELECT>
Region <SELECT NAME="Region">
<OPTION VALUE="ALL">ALL</OPTION>
<OPTION VALUE="North">North</OPTION>
<OPTION VALUE="East">East</OPTION>
<OPTION VALUE="South">South</OPTION>
<OPTION VALUE="West">West</OPTION>
</SELECT>
Return Results Using
<SELECT NAME="ReturnAS">
<OPTION VALUE="HTML">HTML Table</OPTION>
<OPTION VALUE="Content">Content Type</OPTION>
<OPTION VALUE="CSV">CSV</OPTION>
<OPTION VALUE="Excel">Native Excel</OPTION>
</SELECT>
<INPUT TYPE="Submit" NAME="Submit" VALUE="Submit">
</FORM>
</body>
</html>
welcome.htm
<html>
<head>
<title>Sales Report Demo</title>
</head>
<body>
</body>
</html>
数据库结构
testDB.Mdb
表sales
year 数字
Region 文本
Sales_Amt 货币
本文原始出处为国外一网站,并经过BATMAN的休正。
上一页 [1] [2]