麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

ASP利用FSO導(dǎo)出到CSV文件類

2019-11-17 04:12:57
字體:
供稿:網(wǎng)友

程序代碼

<%
'==========================================================
'將紀(jì)錄輸出為(.csv)文件
'制作日期:2003年3月
'作者         :塞北的雪
'==========================================================
Class Export_CSV
   PRivate fso '文件系統(tǒng)對(duì)象
   private fExport
   dim Exp_Type  

   private sub Class_Initialize()
       set FSO= Server.CreateObject("Scr       Exp_Type=1   '導(dǎo)出類型  1為追加方式寫入一個(gè)文件  2為新建一個(gè)新文件再寫入
   end sub
  
   '關(guān)閉對(duì)象
   private sub Class_Terminate()
       fExport.Close
       set FSO=nothing
   end sub
  
   '導(dǎo)出主程序(用數(shù)組指定字段)
   public Function ExportFile(fullpath,
rsset, HeaderArray)
        if Exp_type=1 then
             if not ExistFile(fullpath) then
                if CreateFile(fullpath) then
                   WriteHeader HeaderArray
                   WriteBody rsSet,HeaderArray
                else
                   err_Show "創(chuàng)建文件時(shí)發(fā)生錯(cuò)誤!"
                end if
             else
                
                if OpenFile(fullpath) then
                  WriteBody rsSet,HeaderArray               
                else
                  err_Show "打開文件時(shí)發(fā)生錯(cuò)誤!"                                  
                end if
             end if
        elseif Exp_type=2 then
             if ExistFile(fullpath) then
                   err_Show "文件名沖突!"
             else
                if CreateFile(fullpath) then
                   WriteHeader HeaderArray  
                   WriteBody rsSet,HeaderArray
                else
                   err_Show "創(chuàng)建文件時(shí)發(fā)生錯(cuò)誤!"                                  
                end if
             end if    
        end if
        if err=0 then
           ExportFile=true
        else
           ExportFile=false
        end if
   end function
  
   '指定的標(biāo)題書寫
   public sub WriteHeader( HeaderArray)
         sLine = ""
         for i=0 to ubound(HeaderArray,2)
            sLine=sLine & "," & HeaderArray(0,i)
         next
         if sLine<>"" then      
            sLine=right(sLine,len(sLine)-1)
            fExport.WriteLine(sLine)
         end if
   end sub

'記錄集指定的字段信息輸出
   public sub WriteBody(rsSet, HeaderArray)
     rsSet.movefirst
     Do Until rsSet.EOF
       sLine = ""
       for i=0 to ubound(HeaderArray,2)
          sLine=sLine & "," & rsSet(HeaderArray(1,i))
       next
     
       if sLine <> "" then
         sLine = right(sLine, Len(sLine)-1)
         fExport.WriteLine(sLine)
       end if
       rsSet.MoveNext
     Loop
   end sub
  
  
   '導(dǎo)出主程序(完全記錄集)
    public Function ExportFile2(fullpath,rsSet)
        if Exp_type=1 then
             if not ExistFile(fullpath) then
                if CreateFile(fullpath) then
                   WriteHeader2 rsSet
                   WriteBody2 rsSet
                else
                   err_Show "創(chuàng)建文件時(shí)發(fā)生錯(cuò)誤!"
                end if
             else
                
                if OpenFile(fullpath) then
                  WriteBody2 rsSet               
                else
                  err_Show "打開文件時(shí)發(fā)生錯(cuò)誤!"                                  
                end if
             end if
        elseif Exp_type=2 then
             if ExistFile(fullpath) then
                   err_Show "文件名沖突!"
             else
                if CreateFile(fullpath) then
                   WriteHeader2 rsSet  
                   WriteBody2 rsSet
                else
                   err_Show "創(chuàng)建文件時(shí)發(fā)生錯(cuò)誤!"                                  
                end if
             end if    
        end if
        if err=0 then
           ExportFile2=true
        else
           ExportFile2=false
        end if
   end function
  
   '以字段名為標(biāo)題書寫
   public sub WriteHeader2(rsSet)
         sLine = ""
         for i=0 to rsSet.fields.count-1
            sLine=sLine & "," & rsSet.fields(i).name
         next
         if sLine<>"" then      
            sLine=right(sLine,len(sLine)-1)
            fExport.WriteLine(sLine)
         end if
   end sub

'輸出記錄集中信息
   public sub WriteBody2(rsSet)
     rsSet.movefirst
     Do Until rsSet.EOF
       sLine = ""
       for i=0 to rsSet.fields.count-1
          sLine=sLine & "," & rsSet.fields(i).value
       next
     
       if sLine <> "" then
         sLine = right(sLine, Len(sLine)-1)
         fExport.WriteLine(sLine)
       end if
       rsSet.MoveNext
     Loop
   end sub
  
   '輸出錯(cuò)誤信息
   private sub Err_Show(errDesc)
      Response.Write errDesc
      Response.End
   end sub
  
   '創(chuàng)建一個(gè)文件
   public Function CreateFile(fullpath)
        Set fExport = FSO.CreateTextFile(FullPath, false)
        if err=0 then
           CreateFile=true
        else
           CreateFile=false
        end if
   end function
  
   '打開一個(gè)文件
   public Function OpenFile(fullpath)
            set fExport=FSO.OpenTextFile(fullPath,8,false)
            if err=0 then
               OpenFile=true
            else
              OpenFile=false
            end if
   end function
  
  
   '判斷指定文件名的文件是否存在
   public function ExistFile(fullpath)
       if FSO.FileExists(fullpath) then
           ExistFile=true
       else
           ExistFile=false
       end if 
   end function
     
end Class
%>


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 九九热在线视频观看 | 在线播放黄色网址 | 在线成人免费观看视频 | 成人 日韩 | 姑娘第5集高清在线观看 | 亚洲第一成人久久网站 | 国产精品久久久久久久久久久久久久久久 | 日韩视频一二区 | 91网页 | 免费播放欧美毛片 | 国产超碰人人爽人人做人人爱 | 91羞羞 | 92自拍视频 | 99国产精品欲a | 姑娘第四集免费看视频 | 一色屋任你操 | 李宗瑞国产福利视频一区 | 91九色视频| 欧美黄色免费视频 | 欧美在线观看视频一区二区 | 国产一级免费视频 | 91成人亚洲 | free台湾极品性hd | 久久精品国产99国产精品澳门 | 免费国产一级特黄久久 | 成人三级电影在线 | 成人午夜视频免费 | 久久影院免费观看 | 日韩黄色一区 | av在线免费观看中文字幕 | 九九热这里只有精品8 | 一级网站 | 欧美成人精品一区二区男人小说 | 看毛片免费 | 欧美日本免费一区二区三区 | 男人久久天堂 | 黄色影院在线 | 三人弄娇妻高潮3p视频 | 国产午夜精品久久久久 | 免费观看的毛片手机视频 | 在线日韩av电影 |