用模板生成Excel、Word 最大优点: Word、Excel 文档样式易于控制和调整,以往用Excel.Application 来生成Excel、Word,需要写很多代码来控制排版的样式,用模版几乎不受任何限制,只需要打开 word 或 Excel,编辑文档,选择"文件->另存为 web 页",即可方便的做好模板 ,用office 生成的模板要比直接在 DW 中做好模板更加符合 office 偏好,生成后文件样式可与原 word、Excel 格式 99%一样,因此建议大家用office(office97~office2003)直接来生成模板框架。 主要的代码 function.asp 复制内容到剪贴板代码: <% ''开启容错机制 on error resume next '功能,检测服务器是否支持指定组件 Function object_install(strclassstring) on error resume next object_install=false dim xtestobj set xtestobj=server.createobject(strclassstring) if -2147221005 <> Err then object_install=true set xtestobj=nothing end function if object_install("Scripting.FileSystemobject")=false then Response.Write "
对不起,您的空间不支持FSO 组件,请与管理员联系!
" Response.End end if if object_install("adodb.stream")=false then Response.Write "
对不起,您的空间不支持adodb.stream 功能,请与管理员联系!
" Response.End end if '----------------------------------------------------------------------------- '函数名称:ReadTextFile '作用:利用AdoDb.Stream 对象来读取文本文件 '参数:FileUrl 文件相对路径,FileCharSet:文件编码 Function ReadFromTextFile (FileUrl,FileCharSet)'函数 dim str set stm=server.CreateObject("adodb.stream") stm.Type=2 '指定或返回的数据类型, stm.mode=3 '指定打开模式,现在为可以读写模式,类似于 word 的只读或锁定功能 stm.charset=FileCharSet stm.open stm.loadfromfile serv er.MapPath(FileUrl) str=stm.readtex t ReadFromTex tFile=str End Fu nction...