sql="select 学号,姓名,分数 from 考试记录1,学生 where 编号=学生编号 and 试卷编号=(select 试卷编号 from 试卷 where 考试编号="&id&")and 已阅=1 "
rs.open sql,conn,0,1
if rs.eof then
response.Write "该考试的试卷还未评阅"
else
strAddr = Server.MapPath(".")
excelfile=conn.execute("select 考试名称 from 考试安排 where 编号="&id&"")("考试名称")&"考试成绩单.xls"
set objExcelApp = server.CreateObject("Excel.Application")
objExcelApp.DisplayAlerts = false
objExcelApp.Application.Visible = false
objExcelApp.WorkBooks.add
set objExcelBook = objExcelApp.ActiveWorkBook
set objExcelSheets = objExcelBook.Worksheets
set objExcelSheet = objExcelBook.Sheets(1)
objExcelSheet.Cells(1,1).Value="学号"
objExcelSheet.Cells(1,2).Value="姓名"
objExcelSheet.Cells(1,3).Value="分数"
i=2
while not rs.eof
objExcelSheet.Cells(i,1).Value=rs("学号")
objExcelSheet.Cells(i,2).Value=rs("姓名")
objExcelSheet.Cells(i,3).Value=rs("分数")
rs.movenext
i=i+1
wend
objExcelBook.SaveAs strAddr & "/xls/files/"&excelfile
objExcelApp.Quit
set objExcelApp = Nothing
response.Write "<center>导出成功<br/>"
response.Write "点击<a href='xls/files/"&excelfile&"' target='_blank' οnclick='javascript:window.close()'>打开</a>导出的Excel文件</center>"
rs.open sql,conn,0,1
if rs.eof then
response.Write "该考试的试卷还未评阅"
else
strAddr = Server.MapPath(".")
excelfile=conn.execute("select 考试名称 from 考试安排 where 编号="&id&"")("考试名称")&"考试成绩单.xls"
set objExcelApp = server.CreateObject("Excel.Application")
objExcelApp.DisplayAlerts = false
objExcelApp.Application.Visible = false
objExcelApp.WorkBooks.add
set objExcelBook = objExcelApp.ActiveWorkBook
set objExcelSheets = objExcelBook.Worksheets
set objExcelSheet = objExcelBook.Sheets(1)
objExcelSheet.Cells(1,1).Value="学号"
objExcelSheet.Cells(1,2).Value="姓名"
objExcelSheet.Cells(1,3).Value="分数"
i=2
while not rs.eof
objExcelSheet.Cells(i,1).Value=rs("学号")
objExcelSheet.Cells(i,2).Value=rs("姓名")
objExcelSheet.Cells(i,3).Value=rs("分数")
rs.movenext
i=i+1
wend
objExcelBook.SaveAs strAddr & "/xls/files/"&excelfile
objExcelApp.Quit
set objExcelApp = Nothing
response.Write "<center>导出成功<br/>"
response.Write "点击<a href='xls/files/"&excelfile&"' target='_blank' οnclick='javascript:window.close()'>打开</a>导出的Excel文件</center>"