⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asp中如何在客户端调用execl文件模板进行打印和文件保存.htm

📁 较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0055)http://www.51base.com/article/view_article.asp?id=59447 -->
<HTML lang=zh-cn><HEAD><TITLE>NB联盟</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK 
href="NB联盟21.files/style.css" rel=stylesheet>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY><!-- start page body -->
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 class=td id=position 
width=773>
  <TBODY>
  <TR>
    <TD class=shadow colSpan=2 height=20 width=262>&nbsp;&nbsp;<A 
      href="http://www.51base.com/"><IMG border=0 
      src="NB联盟21.files/logo1.gif"></A> </TD>
    <TD align=right width=505>
      <P align=left></P></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=main width=770>
  <TBODY>
  <TR>
    <TD class=tdlbr vAlign=top>
      <TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=welcome 
      style="TABLE-LAYOUT: fixed" width="98%">
        <TBODY>
        <TR>
          <TD style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" 
            vAlign=top><FONT color=red><B>文章标题</B></FONT><FONT color=red><B>: 
            ASP中如何在客户端调用EXECL文件模板进行打印和文件保存! </B></FONT>
            <HR noShade SIZE=1>
            <BR>小弟初学ASP,现需在后台通过SQL取得数据然后在客户端按照指定的EXECL格式进行 
            &nbsp;<BR>打印,并可以对EXCEL文件进行保存!,最好有实例(分值可再加,急!!!) 
            &nbsp;<BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>你将EXCEL嵌到你的网页中,打印和保存的时候你可以调用你的宏! 
            &nbsp;<BR>如果有不明白的地方可以发mail:zycheng@zhitong.com.cn 
            &nbsp;<BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&lt;% &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;Response.ContentType &nbsp;= &nbsp;"application/msexcel" 
            &nbsp; &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;response.AddHeader &nbsp;"content-disposition", 
            &nbsp;"inline; &nbsp;filename=Book1.xls" &nbsp;<BR>&nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;%&gt; 
            &nbsp;<BR>&nbsp;<BR>filename后面应该跟随你模板文件的位置。 
            &nbsp;<BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>就是生成客户端Excel文件是吧,留下你的email,我给你发代码。 
            &nbsp;<BR>&nbsp;<BR>你也可以搜索Excel关键字,可以得到不少信息的。 
            &nbsp;<BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>' &nbsp;Save &nbsp;to &nbsp;Excel 
            &nbsp;<BR>&nbsp; &nbsp;On &nbsp;Error &nbsp;Resume &nbsp;Next 
            &nbsp;<BR>&nbsp; &nbsp;Set &nbsp;oXL= 
            &nbsp;Server.CreateObject("Excel.Application") &nbsp;<BR>&nbsp; 
            &nbsp;Set &nbsp;fs=Server.CreateObject("Scripting.filesystemobject") 
            &nbsp;<BR>&nbsp; &nbsp;strAppPath &nbsp;= 
            &nbsp;Request.ServerVariables("PATH_TRANSLATED") &nbsp;<BR>&nbsp; 
            &nbsp;strSAppPath &nbsp;= &nbsp;Left(strAppPath, 
            &nbsp;InstrRev(strAppPath, &nbsp;"\"))&amp;"conn\" &nbsp;<BR>&nbsp; 
            &nbsp;strTAppPath &nbsp;= &nbsp;Left(strAppPath, 
            &nbsp;InstrRev(strAppPath, &nbsp;"\"))&amp;"tempfiles\" 
            &nbsp;<BR>&nbsp; &nbsp; &nbsp;<BR>&nbsp; 
            &nbsp;'''''''''''''''''''''''修改部分(文件模板名同生成文件名Begin) &nbsp;<BR>&nbsp; 
            &nbsp;strFileName="mn.xls" &nbsp;<BR>&nbsp; 
            &nbsp;fileroute=strFileName &nbsp;<BR>&nbsp; &nbsp;SFullPath &nbsp;= 
            &nbsp;strSAppPath &nbsp;&amp;"module.xls" &nbsp;<BR>&nbsp; 
            &nbsp;TFullPath &nbsp;= &nbsp;strTAppPath&amp;strFileName &nbsp; 
            &nbsp;<BR>&nbsp;'''''''''''''''''''''''(文件模板名同生成文件名End) 
            &nbsp;<BR>&nbsp; &nbsp;<BR>&nbsp; &nbsp;fs.copyfile 
            &nbsp;SFullPath,TFullPath &nbsp;<BR>&nbsp; &nbsp;set &nbsp;oWB 
            &nbsp;= &nbsp;oXL.Workbooks.Open(TFullPath) &nbsp; &nbsp;<BR>&nbsp; 
            &nbsp;set &nbsp;oSheet1 &nbsp;= &nbsp;oWB.Worksheets(1) 
            &nbsp;<BR>&nbsp; &nbsp; &nbsp;<BR>&nbsp; 
            &nbsp;'''''''''''''''''''''''填充數據Begin) &nbsp;<BR>&nbsp; &nbsp; 
            &nbsp;<BR>&nbsp;<BR>&nbsp;oSheet1.range("d2").value=qmodel 
            &nbsp;<BR>&nbsp;oSheet1.range("d3").value=qline &nbsp;<BR>&nbsp;for 
            &nbsp;j=23 &nbsp;to &nbsp;30 &nbsp; &nbsp; &nbsp;<BR>&nbsp; 
            &nbsp;For &nbsp;i=1 &nbsp;To &nbsp;24'rstcount 
            &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;oSheet1.range(chr(i+66)&amp;cstr(j)).value &nbsp;= 
            &nbsp;temparray(j-23,i-1) &nbsp;<BR>&nbsp; &nbsp;Next 
            &nbsp;<BR>&nbsp; &nbsp;For &nbsp;i=1 &nbsp;to &nbsp;rstcount-23 
            &nbsp;<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp;oSheet1.range("a"&amp;chr(i+64)&amp;cstr(j)).value &nbsp;= 
            &nbsp;temparray(j-23,i+23) &nbsp;<BR>&nbsp; &nbsp;next 
            &nbsp;<BR>&nbsp;next &nbsp;<BR>&nbsp; 
            &nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;for &nbsp;j=32 &nbsp;to &nbsp;33 
            &nbsp; &nbsp; &nbsp;<BR>&nbsp; &nbsp;For &nbsp;i=1 &nbsp;To 
            &nbsp;24'rstcount &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;oSheet1.range(chr(i+66)&amp;cstr(j)).value=temparray(j-24,i-1) 
            &nbsp;<BR>&nbsp; &nbsp;Next &nbsp;<BR>&nbsp; &nbsp;'For &nbsp;i=1 
            &nbsp;to &nbsp;rstcount-23 &nbsp;<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp;'oSheet1.range("A"&amp;chr(i+64)&amp;cstr(j)).value=temparrayy(j-24,i+23) 
            &nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp;'response.Write 
            &nbsp;temparray(j-24,i+23)&amp;"----"&amp;"A"&amp;chr(i+64)&amp;cstr(j)&amp;"-----"&amp;i&amp;"&lt;br&gt;" 
            &nbsp;<BR>&nbsp; &nbsp;'next &nbsp;<BR>next 
            &nbsp;<BR>oSheet1.Range("AA32").value=temparray(8,24) 
            &nbsp;<BR>oSheet1.Range("AB32").value=temparray(8,25) 
            &nbsp;<BR>oSheet1.Range("AC32").value=temparray(8,26) 
            &nbsp;<BR>oSheet1.Range("AD32").value=temparray(8,27) 
            &nbsp;<BR>oSheet1.Range("AE32").value=temparray(8,28) 
            &nbsp;<BR>oSheet1.Range("AF32").value=temparray(8,29) 
            &nbsp;<BR>oSheet1.Range("AA33").value=temparray(9,24) 
            &nbsp;<BR>oSheet1.Range("AB33").value=temparray(9,25) 
            &nbsp;<BR>oSheet1.Range("AC33").value=temparray(9,26) 
            &nbsp;<BR>oSheet1.Range("AD33").value=temparray(9,27) 
            &nbsp;<BR>oSheet1.Range("AE33").value=temparray(9,28) 
            &nbsp;<BR>oSheet1.Range("AF33").value=temparray(9,29) 
            &nbsp;<BR>&nbsp; &nbsp;<BR>&nbsp; 
            &nbsp;'''''''''''''''''''''''(填充數據End) &nbsp;<BR>&nbsp; 
            &nbsp;oWB.Save() &nbsp;<BR>&nbsp; &nbsp;oSheet1.Application.Quit 
            &nbsp;<BR>&nbsp; &nbsp;oXL.Quit &nbsp;<BR>&nbsp; &nbsp;Set 
            &nbsp;oSheet1 &nbsp;= &nbsp;Nothing &nbsp;<BR>&nbsp; &nbsp;Set 
            &nbsp;oWB &nbsp;= &nbsp;Nothing &nbsp;<BR>&nbsp; &nbsp;Set &nbsp;oXL 
            &nbsp;= &nbsp;Nothing 
  &nbsp;<BR>%&gt;<BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0 id=footer width=770>
  <TBODY>
  <TR>
    <TD align=middle class=tdt>
      <P align=center></P></TD></TR></TBODY></TABLE><BR></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -