现在的位置: 首页 > 综合 > 正文

仿智联招聘实现简历导出功能

2013年04月16日 ⁄ 综合 ⁄ 共 5572字 ⁄ 字号 评论关闭

if Trim(request("Action"))="daochu" then
导出到excel

dim Num,xlApplication,xlWorksheet
Num=request.form("BoxId").count
if Num=0 then
Response.Write"<script language=JavaScript>"
  Response.Write"alert(""请选择要导出的数据!"");"
  Response.Write"window.history.go(-1);"
  Response.Write"</script>"
Response.End
end if
 

Set xlApplication = Server.CreateObject("Excel.Application") 调用excel对象
xlApplication.Visible = False 无需打开excel
xlApplication.SheetsInNewWorkbook=Num+1指定excel中表的数量
xlApplication.Workbooks.Add 添加工作簿
for j=1 to Num
Set xlWorksheet = xlApplication.Worksheets(j) 生成第1个工作表的子对象

strSql = "select * from ViewJlTbl where ComId = "& Session("ComId") &" and ViewJlId="&request.form("BoxId")(j)
Set rs =conn.execute(strSql)
Qperson.PersonInfo(rs("PerId"))
while not rs.eof
xlWorksheet.name=j&"、"&Qperson.RealName 指定工作表名称
rs.movenext
wend

 

指定列的宽度以及对齐方式 1左对齐 2右对齐 3居中
xlApplication.ActiveSheet.Columns(1).ColumnWidth=10
xlApplication.ActiveSheet.Columns(1).HorizontalAlignment=3    
xlApplication.ActiveSheet.Columns(2).ColumnWidth=10
xlApplication.ActiveSheet.Columns(2).HorizontalAlignment=3
xlApplication.ActiveSheet.Columns(3).ColumnWidth=20
xlApplication.ActiveSheet.Columns(3).HorizontalAlignment=3

xlApplication.ActiveSheet.Rows(i).RowHeight = 30行的高度
指定列的高度以及特定列
xlWorksheet.Range(xlWorksheet.Cells(1,1), xlWorksheet.Cells(1,2)).MergeCells =True 合并列

 

xlWorksheet.Cells(2,1).Value = "编号"
xlWorksheet.Cells(3,1).Value = "姓名"
xlWorksheet.Cells(4,1).Value = "性别"
xlWorksheet.Cells(5,1).Value = "年龄"
xlWorksheet.Cells(6,1).Value = "籍贯"
xlWorksheet.Cells(7,1).Value = "学历"
xlWorksheet.Cells(8,1).Value = "要求月薪"
xlWorksheet.Cells(9,1).Value = "求职意向"
xlWorksheet.Cells(10,1).Value = "自我评价"
xlWorksheet.Cells(11,1).Value = "专业"
xlWorksheet.Cells(12,1).Value = "目前所在地"
xlWorksheet.Cells(13,1).Value = "联系电话"
xlWorksheet.Cells(14,1).Value = "EMAIL" 

xlWorksheet.Range("A1:B1").Borders.LineStyle=1  设置行style

 

strSql = "select * from ViewJlTbl where ComId = "& Session("ComId") &" and ViewJlId="&request.form("BoxId")(j)
Set rs =conn.execute(strSql)
Qperson.PersonInfo(rs("PerId"))
while not rs.eof

 xlWorksheet.Cells(2,2).Value = Qperson.PerId
 xlWorksheet.Cells(3,2).Value = Qperson.RealName
 xlWorksheet.Cells(4,2).Value = Qperson.Sex
 xlWorksheet.Cells(5,2).Value = Qperson.Age
 xlWorksheet.Cells(6,2).Value = Qperson.Birthplace
 xlWorksheet.Cells(7,2).Value = Qperson.Qualification
 xlWorksheet.Cells(8,2).Value = Qperson.Salary
 xlWorksheet.Cells(9,2).Value = Qperson.JobPost
 xlWorksheet.Cells(10,2).Value = Qperson.pingjia
 xlWorksheet.Cells(11,2).Value = Qperson.zhuanye
 xlWorksheet.Cells(12,2).Value = Qperson.NowAddr
 xlWorksheet.Cells(13,2).Value = Qperson.Tel
 xlWorksheet.Cells(14,2).Value = Qperson.Email

xlWorksheet.Range("A1").value=Qperson.RealName
xlWorksheet.Range("A1").font.Size=14字体大小
xlWorksheet.Range("A1").font.bold=true粗体
xlWorksheet.Range("A1").HorizontalAlignment=3水平对齐
xlWorksheet.Range("A1").VerticalAlignment=3垂直对齐
 rs.movenext
wend

 

next

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

Set xlWorksheet = xlApplication.Worksheets(Num+1) 生成第Num+1个工作表的子对象
xlWorksheet.name="汇总表" 指定工作表名称
指定列的宽度以及对齐方式 1左对齐 2右对齐 3居中
xlApplication.ActiveSheet.Columns(1).ColumnWidth=10 
xlApplication.ActiveSheet.Columns(1).HorizontalAlignment=3    
xlApplication.ActiveSheet.Columns(2).ColumnWidth=10
xlApplication.ActiveSheet.Columns(2).HorizontalAlignment=3
xlApplication.ActiveSheet.Columns(3).ColumnWidth=20
xlApplication.ActiveSheet.Columns(3).HorizontalAlignment=3

xlApplication.ActiveSheet.Rows(i).RowHeight = 30行的高度
指定列的高度以及特定列
xlWorksheet.Range(xlWorksheet.Cells(1,1), xlWorksheet.Cells(1,13)).MergeCells =True 合并列
xlWorksheet.Range("A1").value="汇总表"
xlWorksheet.Range("A1").font.Size=14字体大小
xlWorksheet.Range("A1").font.bold=true粗体
xlWorksheet.Range("A1").HorizontalAlignment=3水平对齐
xlWorksheet.Range("A1").VerticalAlignment=3垂直对齐

xlWorksheet.Cells(2,1).Value = "编号"
xlWorksheet.Cells(2,2).Value = "姓名"
xlWorksheet.Cells(2,3).Value = "性别"
xlWorksheet.Cells(2,4).Value = "年龄"
xlWorksheet.Cells(2,5).Value = "籍贯"
xlWorksheet.Cells(2,6).Value = "学历"
xlWorksheet.Cells(2,7).Value = "要求月薪"
xlWorksheet.Cells(2,8).Value = "求职意向"
xlWorksheet.Cells(2,9).Value = "自我评价"
xlWorksheet.Cells(2,10).Value = "专业"
xlWorksheet.Cells(2,11).Value = "目前所在地"
xlWorksheet.Cells(2,12).Value = "联系电话"
xlWorksheet.Cells(2,13).Value = "EMAIL" 

xlWorksheet.Range("A1:M1").Borders.LineStyle=1  设置行style

--------------------------------------------------自己可做循环i=i+1(数据库数据)

for m=1 to Num

strSql = "select * from ViewJlTbl where ComId = "& Session("ComId") &" and ViewJlId="&request.form("BoxId")(m)
Set rs =conn.execute(strSql)
Qperson.PersonInfo(rs("PerId"))
while not rs.eof
 xlWorksheet.Cells(2+m,1).Value = Qperson.PerId
 xlWorksheet.Cells(2+m,2).Value = Qperson.RealName
 xlWorksheet.Cells(2+m,3).Value = Qperson.Sex
 xlWorksheet.Cells(2+m,4).Value = Qperson.Age
 xlWorksheet.Cells(2+m,5).Value = Qperson.Birthplace
 xlWorksheet.Cells(2+m,6).Value = Qperson.Qualification
 xlWorksheet.Cells(2+m,7).Value = Qperson.Salary
 xlWorksheet.Cells(2+m,8).Value = Qperson.JobPost
 xlWorksheet.Cells(2+m,9).Value = Qperson.pingjia
 xlWorksheet.Cells(2+m,10).Value = Qperson.zhuanye
 xlWorksheet.Cells(2+m,11).Value = Qperson.NowAddr
 xlWorksheet.Cells(2+m,12).Value = Qperson.Tel
 xlWorksheet.Cells(2+m,13).Value = Qperson.Email
 rs.movenext
wend

next
dim nowfilename,tfile,fs,f,link
nowfilename=replace(replace(replace(now,":","")," ",""),"/","")
filename=""&nowfilename&".xls"
filename="excel/"& Session("ComId") &".xls"
Set fs = CreateObject("Scripting.FileSystemObject")
tfile=Server.MapPath(filename)
if fs.FileExists(tfile) then
Set f = fs.GetFile(tfile)
f.delete true
Set f = nothing
end if
Set fs = nothing
xlWorksheet.SaveAs tfile 保存文件
xlApplication.Quit 释放对象
Set xlWorksheet = Nothing
Set xlApplication = Nothing
 

link="<p align=center><A HREF=downfile.asp?fileSpec="&tfile&" title=将数据保存至Eecel表中><font color=red><b>导出excel文件</b></font></a></p>"
Response.write link
end if

抱歉!评论已关闭.