asp导出execl

< %
dim  connDB
set  connDB = server.CreateObject( " adodb.connection " )
    connDB.open(
" database=test;uid=sa;pwd=;driver={sql server};server=. " )
set  connEXCEL = server.CreateObject( " adodb.connection " )
    connEXCEL.Open 
" Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath( " 1.xls " ) & " ; "   &   " Extended Properties=""Excel 8.0;HDR=Yes;""; "
    
    
function  getType(rs)    
    sql
= " select distinct u_type from liuyan "
    
set  rs = server.CreateObject( " adodb.recordset " )
    rs.Open sql,connDB,
1 , 1
End function

function  getData(rs1)
    sql1 
=   " select id,name,u_type from liuyan where u_type=' "   &  rs( " u_type " &   " ' "
    
set  rs1  =  server.createobject( " adodb.recordset " )
    rs1.open sql1,connDB,
1 , 1
end function

function  createTable()   
    connEXCEL.Execute 
" create table  " & rs( " u_type " ) & " (id varchar(10),name text,type varchar(255)) "
end function

function  insertTable()
     connEXCEL.execute 
" insert into [ "   &  rs( " u_type " &   " $] values(' "   &  rs1( " id " &   " ',' "   &  rs1( " name " &   " ',' "   &  rs1( " u_type " &   " ') "
     Response.Write 
" hello "
end function

getType rs
do   while   not  rs.eof
    createTable
    getData rs1
    
do   while   not  rs1.EOF
        insertTable
    rs1.MoveNext
    
loop
rs.movenext
loop

connEXCEL.Close()
connDB.Close()
%
>

你可能感兴趣的:(exec)