<HTML>
<HEAD>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb_2312-80">
<link rel="stylesheet" type="text/css" href="edit.css">
<title>保存为Word文档</title>
</HEAD>
<script language="javascript">
window.returnValue=0
</script>
<BODY>
<font color="#000080"><strong><div id="strHint" align="center">数据处理中,请等待...<br>
Data processing, please wait...</div></strong></font><font color="#0080C0">
<!--#include file="../inc/function.asp"-->
<%
Function GetUrl()
On Error Resume Next
Dim strTemp
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & Request.ServerVariables("SERVER_NAME")
If Request.ServerVariables("SERVER_PORT") <> 80 Then
strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT")
end if
GetUrl = strTemp
End Function
set objcn = server.CreateObject("gdcom.database")
set rs = server.CreateObject("ADODB.Recordset")
set fso = Server.Createobject("Scripting.FileSystemObject")
set stm=server.createobject("ADODB.Stream")
kch=trans(request.QueryString("kch"))
kch="5201000100002005120001"
links=GetUrl
'response.Write(Server.mappath("."))
'response.end
strsql="select * from xcpic where kch='"&kch&"' and qtype='现场照片' order by lrsj"
'strSQL="select unitname from tblunit where unitid='"&session("unitid")&"'"
set rs = objcn.RunSQLReturnRS(strSQL)
if rs.recordcount=0 then
response.Write("<script language=javascript>alert('暂无现场图片!');window.opener=null;window.close();</script>")
response.end
end if
tablerow=rs.recordcount*2
execute "dim tu("&rs.recordcount&","&rs.recordcount&")"
rs.movefirst
for i=1 to tablerow/2
tu(i,1)=rs("title")
If Not IsNull(rs("wjlj")) Then
AttachmentFile = Server.mappath(".") & "/photo/" & Session.SessionID & "_PICTURE[" & i & "].JPG"
stm.Mode = 3
stm.Type = 1
stm.Open
stm.Write rs("wjlj")
stm.SaveToFile AttachmentFile, 2
stm.Close
End If
AttachmentFile1=links&"/xk/photo/" & Session.SessionID & "_PICTURE[" & i & "].JPG"
'If fso.FileExists(AttachmentFile) Then
' fso.DeleteFile AttachmentFile
'End If
tu(i,2)=AttachmentFile1
rs.movenext
next
rs.close
%>
<script language="vbscript">
Dim wApp
Set wApp = CreateObject("Word.Application")
If Err.number > 0 Then
Alert "没法保存为Word文件,请正确安装Word"
else
wApp.visible = True
wApp.Documents.add
wApp.Selection.ParagraphFormat.LineSpacing = 30
wApp.Selection.TypeParagraph
With wApp.Selection
.Font.Bold = False
.ParagraphFormat.Alignment = 1
.Font.Name = "仿宋_GB2312"
.Font.Size = 16
End With
Set rngCurrent = wApp.Application.ActiveDocument.Paragraphs(1).Range
Set tabCurrent = wApp.Application.ActiveDocument.Tables.Add(rngCurrent,<%=tablerow%>,1)
<%for i=1 to tablerow/2%>
wApp.Application.ActiveDocument.Tables(1).Rows(<%=(i*2-1)%>).Cells(1).Range.InlineShapes.AddPicture "<%=tu(i,2)%>", False, True
wApp.Application.ActiveDocument.Tables(1).Rows(<%=(i*2-1)%>).Cells(1).Range.ParagraphFormat.alignment=1
wApp.Application.ActiveDocument.Tables(1).Rows(<%=(i*2)%>).Cells(1).Range.InsertAfter "<%=tu(i,1)%>"
wApp.Application.ActiveDocument.Tables(1).Rows(<%=(i*2)%>).Cells(1).Range.ParagraphFormat.alignment=1
<%next%>
end if
</script>
/////最后的删除不要了,是异步的,这么快删除,图片还没导入到word中...
<%
apppath=server.mappath(".")
apppath=apppath&"/photo/"
links1=links&"/xk/photo/"
for i=1 to tablerow/2
filepic=replace(tu(i,2),links1,apppath)
If fso.FileExists(filepic) Then
fso.DeleteFile filepic
End If
next
%>
<center><br><strong>数据处理完毕!</strong></center>
<p>
</p><div align='center'><center><input type=button class=buttonface name='cmdOK' onclick="window.returnValue=0;window.close();" value=" 确 定 " ></center></div>
</BODY>
</HTML>