asp显示文件夹中的excel文件解决办法

asp显示文件夹中的excel文件
<%@ LANGUAGE = VBScript CodePage = 936%>
<%
Option Explicit
Response.Buffer = True
dim MaxPerPage,MyPath
dim CurrentPage,PageCounts,FolderCounts,path,goparent,pathurl,s_folderpath
dim obj_fso,obj_folder,s_folder
dim cname,ename
dim bg
MaxPerPage=20
MyPath="C:\Inetpub\wwwroot\luck\hello\rikuangbiao"
path=trim(request.querystring("path"))
CurrentPage=trim(request.querystring("page"))
if path="" or instr(path," ")>0 or instr(path,vbcrlf)>0 or instr(path,":")>0 or instr(path,"\")>0 then
 path="/"
elseif right(path,1)<>"/" then
 path=path&"/"
elseif left(path,1)<>"/" then
 path="/"&path
end if

If CurrentPage<>"" And isNumeric(CurrentPage) Then
 CurrentPage=Cint(CurrentPage)
Else
 CurrentPage=1
End If
if path="/" then
 goparent="根目录"
else
 goparent="<a href=""?path="&server.urlencode(left(path,instrrev(path,"/",len(path)-1)))&""">返回上级目录"
end if
pathurl=server.urlencode(path)
's_folderpath=server.mappath(path)
s_folderpath=MyPath&replace(path,"/","\")
set obj_fso=server.createobject("scripting.filesystemobject")
%>
<html>
<head>
<title>历史日况表</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<link rel="stylesheet" href="inc/style.css" type="text/css">
<head>
<body topmargin=0 leftmargin=3 rightmargin=3>
<%
if obj_fso.folderexists(s_folderpath) then
%>

        <%
 dim s_classname,s_classpath,s_classurl
 dim i
 i=1
 FolderCounts=0
 set obj_folder=obj_fso.getfolder(s_folderpath)
 for each s_folder in obj_folder.subfolders
  s_classname=s_folder.name
  s_classpath=path&s_classname
  s_classurl=server.urlencode(s_classpath)
  if FolderCounts mod 2=0 then
   bg=" bgcolor='#ffffff'"
  else
   bg=""
  end if
%>
        <%
         FolderCounts=FolderCounts+1
         i=i+1
 next
%>
        <tr>
          
        </tr>
        </form>
      </table>
    </td>
    <td width="5"> </td>
    <td height="100%" valign="top">
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#E8F1FF">
        <tr height="28" bgcolor="#C8D6F0" align="center">
          <td width="38%"><b>文件名</b></td>
          <td width="9%"><b>文件大小</b></td>
          <td width="20%"><b>最后修改时间</b></td>
        </tr><%
 dim startnum,TotleSize,s_file,s_filename,FileCounts,FileName,FileExt,s_pathurl
 i=1
 startnum=(CurrentPage-1)*MaxPerPage
 TotleSize=0
 for each s_file in obj_folder.files
   FileCounts=FileCounts+1
 next
 if FileCounts mod MaxPerPage=0 then
  PageCounts=FileCounts\MaxPerPage
 else
  PageCounts=FileCounts\MaxPerPage+1
 end if
 If CurrentPage<1 Then
  CurrentPage=1
 End If
 if CurrentPage>PageCounts then
  CurrentPage=PageCounts
 end if
 for each s_file in obj_folder.files
  s_filename=s_file.name
  s_pathurl=server.urlencode(path&s_filename)
  if (i-1) mod 2=0 then
   bg=" bgcolor='#ffffff'"
  else
   bg=""
  end if
  FileName=GetFileName(s_filename)
  FileExt=GetFileExt(s_filename)
  if i>startnum then
   TotleSize=TotleSize+s_File.Size
%>
        <tr height="22" align="center"<%=bg%>>
          <td align="center"> <% response.write  "<a href='hello/biao/"& s_file.name & "' target='_blank'>" &s_file.name & "</a>"  %></td>
          <td><%=ByteNum(s_file.size)%></td>
          <td><%=s_file.datelastmodified%></td>
        </tr><%
  end if
  if i>startnum+MaxPerPage then
   exit for
  end if
  i=i+1
 next
%>
        <tr>
          <td height="22" colspan=3 align=right bgcolor="#C8D6F0"><%
 if CurrentPage>1 then
  response.write "<a href='?path="&pathurl&"&page="&(CurrentPage-1)&"'>上一页</a> "
 end if
 response.write "本目录共有"&obj_folder.files.count&"个文件 本页文件为"&ByteNum(TotleSize)&"B 当前第 "
 response.write "<select name='jtp' style='line-height:15px;border:none;height:12px;padding:0' onchange="&chr(34)&"window.location.href='?page='+(this.options.selectedIndex+1)+'&path="&pathurl&"'"&chr(34)&">"&vbcrlf
 for i=1 to PageCounts
  if i=CurrentPage then
   response.write "<option selected>"&i&vbcrlf
  else
   response.write "<option>"&i&vbcrlf
  end if
 next
 response.write "</select> 页 共"&PageCounts&"页 "
 if CurrentPage<PageCounts then
  response.write "<a href='?path="&pathurl&"&page="&(CurrentPage+1)&"'>下一页</a> "
 end if
%>
          </td>
        </tr>
        <tr>
          <td height="100%" colspan=3 bgcolor="#F8FAFE"></td>
        </tr>
        </form>
      </table>
    </td>
  </tr>
</table><%
 set obj_folder=nothing
else
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#E8F1FF">
  <tr>
    <td height="80" align="center" bgcolor="#FFFFFF" style="color:#ff3333;font-weight:600">目录不存在!</td>
  </tr>
</table><%
end if
set obj_fso=nothing
%>
</center>
</body>
</html><%
function getname(s_string,s_clipchar)
 n_strpos=instrrev(s_string,s_clipchar)
 getname=lcase(right(s_string,len(s_string)-n_strpos))
end function
Function GetFileName(lpFullFileName)
 Dim nDotPos
 If InStr(lpFullFileName,".")=0 Then
  GetFileName=lpFullFileName
  Exit Function
 End If
 nDotPos=InStrRev(lpFullFileName,".")
 GetFileName=Left(lpFullFileName,nDotPos-1)
End Function
Function GetFileExt(lpFullFileName)
 Dim fnArray
 If InStr(lpFullFileName,".")=0 Then
  Exit Function
 End If
 fnArray=Split(lpFullFileName,".")
 GetFileExt=fnArray(UBound(fnArray))
End Function
'--------格式文件尺寸显示
Function ByteNum(num)
 if Num=0 then
  ByteNum="0K"
 elseif Num<1024 then
  ByteNum="1K"
 else
  ByteNum=formatNumber(int(Num/1024),0)&"K"
 end if
 ' ByteNum=Num&" Byte"
 'elseif Num<1048576 then
 ' ByteNum=formatNumber(int(Num/1024),0)&" KB"
 'elseif Num<1073374812 then
 ' ByteNum=formatNumber(int(Num/1048576),0)&" MB"
 'elseif Num<1073374812 then
 'else
 ' ByteNum=formatNumber(int(Num/1073374812),0)&" GB"
 'end if
End function
%>





文件的命名是xxxx年xx月xx日   想要逆序排列就是时间越大的排在越前面
------解决思路----------------------
asp显示文件夹中的excel文件解决办法