利用ASP制作EXECL报表方法(二)

2016-01-29 17:22 2 1 收藏

利用ASP制作EXECL报表方法(二),利用ASP制作EXECL报表方法(二)

【 tulaoshi.com - ASP 】

  废话少说,请看代码:
runquery.asp

<%@ LANGUAGE="VBSCRIPT" %
<%
'DSNless connection to Access Database
strDSNPath = "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("testDB.mdb")
%
<!--#include file="adovbs.inc" --  请自己COPY这个文件
<%      
        server.scripttimeout=1000
    Response.Buffer    = True
    
    if(Request.Form("ReturnAS") = "Content") then
        Response.ContentType = "application/msexcel"
    end if
    Response.Expires = 0
    
    dim oConn
    dim oRS
    dim strSQL
    dim strFile
        
    Set oConn = Server.CreateObject("ADODB.Connection")
    Set oRS = Server.CreateObject("ADODB.Recordset")
    strSQL = BuildSQL()
        
    oRS.Open strSQL, strDSNPath, adOpenForwardOnly, adLockReadOnly, adCmdText
%
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"

<html
<head
    <titleExcel Export Demo</title
</head
<body
<%
    if(Request.Form("ReturnAS") = "CSV") then
        CreateCSVFile()
    else if(Request.Form("ReturnAS") = "Excel") then
        CreateXlsFile()        
    else if(Request.Form("ReturnAS") = "HTML") then
        GenHTML()
    else if(Request.Form("ReturnAS") = "Content") then
        GenHTML()        
    end if
    end if
    end if
    end if
   
    Set oRS = Nothing
    Set oConn = Nothing        
    Response.Flush
%
</body
</html
<SCRIPT LANGUAGE=vbscript RUNAT=Server
Function BuildSQL()
    dim strSQL
    dim strTemp
    
    strTemp = ""
    strSQL = "select year, region, sales_amt from sales"
    
    if(Request.Form("Year") < "ALL") then
        strTemp = " where Year = "
        strTemp = strTemp & Request.Form("Year")
    end if
    
    if(Request.Form("Region") < "ALL") then
        if(Len(strTemp) 0) then
            strTemp = strTemp & " and Region = "
        else
            strTemp = strSTL & " where Region = "
        end if
   &nb

来源:https://www.tulaoshi.com/n/20160129/1501123.html

延伸阅读
标签: 家有妙招
把一定量的淘米水倒入水池内,混浊的水会变得清澈明净。经常往鱼池里倒淘米水。不仅增强了鱼的营养,而且也使池水保持清洁。 旧浴帽防止座垫被淋湿 雨天将旧浴帽套在自行车坐垫上,可保证坐垫不被淋湿。 废瓶盖去鱼鳞既快又安全 将五六个啤酒瓶或饮料瓶盖,交错地固定在一块木板上,留出把手,用它来刮鱼鳞,既快又...
标签: Web开发
以下内容为程序代码: 在我们对VS.Net中的水晶报表(Crystal Reports)进行研究之前,我和我朋友对如何将这个复杂的东东加入我们的Web应用有着非常的好奇心。一周以后,在阅读了大量的“HOWTO”文档之后,我们成功地将一些简单的报告加入到了我们的Asp.net程序中,并得到了一些小决窍。 这篇文章教你如何在.Net Web应用中使用水晶报...
报表作为系统信息的典型输出形式之一,是大多数应用系统非凡是MIS系统的重要功能。是否具有一个良好的打印功能,往往从一定程度上关系到系统的成败。Delphi有很强的报表功能,但是它的报表功能还不能满足我们的需要。于是许多Delphi高手相继推出了不少优秀的报表控件(模块),作为QuickReport的补充,其中FastReport就是一个代表。 Fa...
标签: ASP
  Using the global.asa to schedule ASP code execution. Have you ever had some asp code that needed to execute every once in a while but, you just didn't know how to do it. There is a solution that doesn't involve running any scheduling or scripting software on the server and is actually very easy to get working....
标签: ASP
  先贴一篇较简单的用ASP+RDS客户端参生报表 此文希望能进精华篇 下一回贴一篇较复杂的 说明:(若提示ActiveX 元件无法参生 RDS.DataSpace) IE需设置安全选项 操作:菜单工具-INTERNET选项-安全性-自定义 设置 起始但ActiveX不标示为安全-开启 <html <head <META content="text/html; charset=gb2312" http-equiv=...

经验教程

247

收藏

87
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部