{"id":576,"date":"2007-10-09T13:53:29","date_gmt":"2007-10-09T13:53:29","guid":{"rendered":"http:\/\/fanhaijun.com\/?p=576"},"modified":"2009-05-12T00:19:51","modified_gmt":"2009-05-11T16:19:51","slug":"%e5%b0%b1%e4%b8%9a%e6%8c%87%e5%af%bc%e8%af%be%e7%9a%84%e8%80%83%e5%8b%a4%e8%a1%a8%e7%94%9f%e6%88%90%e4%bb%a3%e7%a0%81%e5%af%bc%e5%87%baexcel","status":"publish","type":"post","link":"https:\/\/fanhaijun.com\/?p=576","title":{"rendered":"\u5c31\u4e1a\u6307\u5bfc\u8bfe\u7684\u8003\u52e4\u8868\u751f\u6210\u4ee3\u7801[\u5bfc\u51faexcel]"},"content":{"rendered":"<pre lang=\"asp\"><!--#include file=\"conn.asp\"-->\r\n\r\n<!--Server.ScriptTimeOut=2147483647\r\n'On Error Resume Next\r\nstrAddr=Server.MapPath(\".\")\r\nSet rs=Server.Createobject(\"ADODB.RecordSet\")\r\nSet rs_year=Server.Createobject(\"ADODB.RecordSet\")\r\nSet rs_class=Server.Createobject(\"ADODB.RecordSet\")\r\n\r\nrs.open \"SELECT * From \u9662\u522b order by \u9662\u522b\",conn,1,1 '\u9009\u51fa\u9662\u522b\u8868\r\n\r\nfor i=0 to rs.RecordCount-1\r\nif not rs.eof then\r\nSet fso = CreateObject(\"Scripting.FileSystemObject\")\r\nresponse.write rs(\"\u9662\u522b\")&#038;\"\"\r\ncol_name=rs(\"\u9662\u522b\")\r\n  if fso.folderexists(strAddr&#038;\"\\\u5b8c\u6210\\\"&#038;col_name)=false then\r\n    Fso.Createfolder(strAddr&#038;\"\\\u5b8c\u6210\\\"&#038;col_name)\r\n'''''''''''''''''''''''''''''''''''''''''''\r\n      rs_year.open \"SELECT * From \u5165\u5b66\u65f6\u95f4 order by \u5165\u5b66\u65f6\u95f4\",conn,1,1 '\u9009\u51fa\u5165\u5b66\u65f6\u95f4\u8868\r\n      for k=0 to rs_year.RecordCount-1\r\n      if not rs_year.eof then\r\n      response.write rs_year(\"\u5165\u5b66\u65f6\u95f4\")&#038;\"\"\r\n          year_name=rs_year(\"\u5165\u5b66\u65f6\u95f4\")\r\n          Set fso_year = CreateObject(\"Scripting.FileSystemObject\")\r\n          if fso_year.folderexists(strAddr&#038;\"\\\u5b8c\u6210\\\"&#038;col_name&#038;\"\\\"&#038;year_name)=false then\r\n            fso_year.Createfolder(strAddr&#038;\"\\\u5b8c\u6210\\\"&#038;col_name&#038;\"\\\"&#038;year_name)\r\n'===========================================\r\n          '\u586b\u5145excel\r\n      rs_class.open \"SELECT * From \u73ed\u522b where \u5165\u5b66\u65f6\u95f4='\"&#038;year_name&#038;\"' and \u9662\u522b='\"&#038;col_name&#038;\"' order by \u73ed\u522b\",conn,1,1 '\u9009\u51fa\u73ed\u522b\u8868\r\n        for j=0 to rs_class.RecordCount-1\r\n\r\n        if not rs_class.eof then\r\n          response.write rs_class(\"\u73ed\u522b\")&#038;\"\"\r\n          class_name=rs_class(\"\u73ed\u522b\")\r\n          zhuanye_name=rs_class(\"\u4e13\u4e1a\u540d\u79f0\")\r\n'##############################################################################\r\nset objExcelApp=CreateObject(\"Excel.Application\")\r\nobjExcelApp.DisplayAlerts=false\r\nobjExcelApp.Application.Visible=false\r\n\r\nobjExcelApp.WorkBooks.Open(strAddr&#038;\"\\Database\\Null.xls\")\r\nset objExcelBook=objExcelApp.ActiveWorkBook\r\nset objExcelSheets=objExcelBook.Worksheets\r\nset objExcelSheet=objExcelBook.Sheets(1)\r\n\r\nobjExcelSheet.Cells(1,1).Value=\"\u8087\u5e86\u5b66\u9662\"&#038;year_name&#038;\"\u7ea7\u300a\u5c31\u4e1a\u6307\u5bfc\u300b\u8bfe\u5b66\u751f\u6210\u7ee9\u4e00\u89c8\u8868\"\r\nobjExcelSheet.Cells(2,1).Value=\"\u8bfe\u7a0b\u540d\u79f0\uff1a\u300a\u5f62\u52bf\u4e0e\u653f\u7b56\uff08\u5c31\u4e1a\u6307\u5bfc\uff09\u300b\u3000\u5b66\u5206\uff1a2\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u4e13\u4e1a\uff1a\"&#038;zhuanye_name&#038;\" \u3000\u73ed\u7ea7\uff1a\"&#038;class_name&#038;\"\"\r\n\r\nSet rs_stu=Server.Createobject(\"ADODB.RecordSet\")\r\nrs_stu.open \"SELECT * From allstu where \u73ed\u522b='\"&#038;class_name&#038;\"' order by \u5b66\u53f7 \",conn,1,1 '\u9009\u51fa\u5b66\u751f\u8868\r\ntotal_count=rs_stu.RecordCount\r\nFor m = 0 To total_count-1\r\nobjExcelSheet.Rows(\"6:6\").Insert\r\nNext\r\nm=0\r\nFor m = 0 To total_count-1\r\n  if not rs_stu.eof then\r\n    objExcelSheet.Cells(6+m,1).Value=m+1\r\n    objExcelSheet.Cells(6+m,2).Value=rs_stu(\"\u5b66\u53f7\")\r\n    objExcelSheet.Cells(6+m,3).Value=rs_stu(\"\u59d3\u540d\")\r\n  end if\r\n  rs_stu.movenext\r\nNext\r\nrs_stu.close\r\nSet rs_stu=nothing\r\n\r\nobjExcelBook.SaveAs(strAddr&#038;\"\\\u5b8c\u6210\\\"&#038;col_name&#038;\"\\\"&#038;year_name&#038;\"\\\"&#038;rs_class(\"\u73ed\u522b\")&#038;\".xls\")\r\n\r\nobjExcelApp.Quit\r\nset objExcelApp=Nothing\r\n\r\n'##############################################################################\r\n        end if\r\n        rs_class.movenext\r\n        next\r\n      rs_class.close\r\n'==========================\r\n          end if\r\n        Set fso_year=nothing\r\n      end if\r\n\r\n      rs_year.movenext\r\n      next\r\n      rs_year.close\r\n'''''''''''''''''''''''''''''''''''''''''''''''''\r\n  end if\r\nSet fso=nothing\r\nend if\r\n\r\nrs.movenext\r\nnext\r\n\r\nrs.close\r\nSet rs_year=nothing\r\nSet rs=nothing\r\n\r\n-->\r\n<!--CTYPEHTMLPUBLIC\"-\/\/W3C\/\/DTDHTML4.0Transitional\/\/E-->\r\n\r\n\u5b8c\u6210\uff01<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b8c\u6210\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[104],"tags":[],"class_list":["post-576","post","type-post","status-publish","format-standard","hentry","category-technogy"],"_links":{"self":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=576"}],"version-history":[{"count":0,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/576\/revisions"}],"wp:attachment":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}