仿智聯招聘實現簡歷導出功能

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

發佈了40 篇原創文章 · 獲贊 24 · 訪問量 54萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章