写excel
<%
response.write Server.MapPath("fso/")
Set ExcelApp =CreateObject("Excel.Application")
ExcelApp.Application.Visible = True
Set ExcelBook = ExcelApp.Workbooks.add
ExcelApp.Range(ExcelApp.Cells(1, 1), ExcelApp.Cells(1, 4)).Merge'合并单元格
ExcelBook.WorkSheets(1).cells(1,1).value ="用户表"
ExcelBook.WorkSheets(1).cells(2,1).value = "用户编号"
ExcelBook.WorkSheets(1).cells(2,2).value = "登陆名"
ExcelBook.WorkSheets(1).cells(2,3).value = "真实姓名"
ExcelBook.WorkSheets(1).cells(2,4).value = "密码"
cnt =3
For i=3 To 6
ExcelBook.WorkSheets(1).cells(cnt,1).value = "1111"
ExcelBook.WorkSheets(1).cells(cnt,2).value = "22222"
ExcelBook.WorkSheets(1).cells(cnt,3).value = "33333"
ExcelBook.WorkSheets(1).cells(cnt,4).value = "ds"
cnt = cint(cnt) + 1
Next
ExcelApp.Range("B3:k3").Value=Array("67","87","5","9","7","45","45","54","54","10")'区段添加数据
Excelbook.SaveAs Server.MapPath("fso/1.xls") '这个是数据导出完毕以后在D盘存成文件
ExcelApp.Application.Quit '导出以后退出Excel
Set ExcelApp = Nothing '注销Excel对象
%>
读取execle
<%
dim myconnection
set myconnection=server.createobject("adodb.connection")
dim myconnectionstr
myconnectionstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("fso/2.xls")&";Extended Properties=Excel 8.0;"
myconnection.open myconnectionstr
dim myrecordset
set myrecordset=server.createobject("adodb.recordset")
dim mysql
mysql="select * from [sheet1$]"
myrecordset.open mysql,myconnection,1,1
do while not myrecordset.eof
response.write myrecordset(0) &" "& myrecordset(1)&" "&myrecordset(1) &" "&myrecordset(3)&" "&myrecordset(4) & "<br>"
myrecordset.movenext
loop
set myrecordset=nothing
set myconnection=nothing
'默认excel的第一行不读取。作为标题页
%>