开发学院WEB开发ASP ASP生成输出DOC(Word文件) 阅读

ASP生成输出DOC(Word文件)

 2009-05-06 10:40:01 来源:WEB开发网   
核心提示:< %const lie=3 '修改列数const tablewidth="33%" '定义表格的宽度const tableheight="18%" '定义表格的高度const imgwidth="15%" '定义表格的

< %
const lie=3   '修改列数
const tablewidth="33%" '定义表格的宽度
const tableheight="18%" '定义表格的高度
const imgwidth="15%" '定义表格的宽度
const imgheight="27.5%" '定义表格的高度
const fontsize="12px;" '定义文字的大小
const txtwidth="120"   '图片右侧文字表格宽
const txtheight="18%"   '图片右侧文字表格高
const txtalign="left"   '图片右侧文字对齐方式:left左,center中,right右

'TOP 强调该文件为Word文件
function doctop()
   doctop="<html xmlns:v=""urn:schemas-microsoft-com:vml"" xmlns:o=""urn:schemas-microsoft-com:office:office"" xmlns:w=""urn:schemas-microsoft-com:office:word"" xmlns=""http://www.w3.org/TR/REC-html40""><head><title>生成结果</title><meta http-equiv=Content-Type content=""text/html; charset=gb2312""></meta><meta name=PRogId content=Word.Document></meta><meta name=Generator content=""Microsoft Word 10""></meta><meta name=Originator content=""Microsoft Word 10""><style type=""text/CSS"">@page Section1{margin:30pt 8.5pt 5.65pt 12pt;}div.Section1{page:Section1;}table{font-size:"&fontsize&"}</style></meta></head>"+chr(13)+chr(10)
end function

function imgtotable(fto,fpar,dext)
   imgtotable="<table width="&tablewidth&" height="&tableheight&" border=0>"
   imgtotable=imgtotable+"<tr valign=""top""><td><img src="""&replace(demo,fpar,"")&""" width="""&imgwidth&""" height="""&imgheight&"""/></td>"
   imgtotable=imgtotable+"<td colspan=""2"" align=""center"">"
   imgtotable=imgtotable+"<table width="&txtwidth&" height="&txtheight&"><tr><td align="""&txtalign&""">"&replace(lcase(fto.name),"."&dext,"")&"</td></tr><tr><td align="""&txtalign&""">演员</td></tr><tr><td align="""&txtalign&""">语言</td></tr><tr><td align="""&txtalign&""">容量</td></tr><tr><td align="""&txtalign&""">类型</td></tr></table>"
   imgtotable=imgtotable+"</td></tr></table>"+chr(13)+chr(10)
end function


function imagetodoc(fpath,fpar)
   set fto=fso.createtextfile(fpath&"/运行结果.doc",True)
   fto.writeline doctop()
   fto.writeline "<body topmargin=0 leftmargin=0><table width=""64"" height=""100%"" border=1><div class=Section1>"
   for each demo in fpath.files
     dext=Lcase(fso.getExtensionName(demo))
     if dext="jpg" or dext="gif" or dext="png" then
       if (i mod lie)=0 then fto.writeline "   <tr>"+chr(13)+chr(10)
       i=i+1
       fto.writeline "<td>"
       '用于排错
       'fto.writeline "123"
       fto.writeline imgtotable(demo,fpar,dext)
       fto.writeline "</td>"+chr(13)+chr(10)
       if (i mod lie)=0 then i=0:fto.writeline "   </tr>"+chr(13)+chr(10)
     end if
   next
   fto.close
   response.write "</div></table></body>"
   response.write ""&fpo&fpath&"\运行结果.doc"" 生成完毕。<br />"
   set fto=nothing
end function

set fso=server.createobject("scripting.filesystemobject")
set fpo=fso.getfolder(server.mappath("./"))
for each demo in fpo.subfolders
   call imagetodoc(demo,"")
next
set fpo=nothing
set fso=nothing
%>

Tags:ASP 生成 输出

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接