你的模板可以作成txt/excel/word,等等,我建议是excel,然后存放在你的web目录里,具体:
set objApp = CreateObject("Excel.Application")
set objApp1 = CreateObject("Excel.Application")
set objBook1 = objApp1.Workbooks.Add()
strPath="c:/webroot/doc/templete.xls" '模板路径
set objBook = objApp.Workbooks.Open(strPath)
set objSheet = objBook.Worksheets(1)
if iSheetCounts > 3 then 'Excel中1个Workbook默认有三个工作表
set objSheet1 = objBook1.Worksheets.Add()
else
set objSheet1 = objBook1.Worksheets(iSheetCounts)
iSheetCounts = iSheetCounts+1
end if
for x = 1 to 45
for y = 1 to 15
if trim(objSheet.Cells(x,y)) <> "" then
strText = objSheet.Cells(x,y)
if instr(1,strText,"<Date>") > 0 then
strText = replace(strText,"<Date>",arr(13)) 'Date())
end if
end if
objSheet1.Cells(x,y) = strText
next
next
set objApp =nothing
set objApp1 =nothing
set objBook1 =nothing
set objSheet = nothing
set objSheet1 = nothing
2、分页打印
<HTML>
<HEAD>
<STYLE>
P {page-break-after: always}
</STYLE>
</HEAD>
<BODY>
<%while not rs.eof%>
<P><%=rs(0)%></P>
<%rs.movenext%>
<%wend%>
</BODY>
</HTML>
3、ASP页面打印时如何去掉页面底部的路径和顶端的页码编号
(1)ie的文件-〉页面设置-〉讲里面的页眉和页脚里面的东西都去掉,打印就不出来了。
(2)<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="YC">
<script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"
'//设置网页打印的页眉页脚为空
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
'//设置网页打印的页眉页脚为默认值
function pagesetup_default()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P"
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"
end function
</script>
</HEAD>