首页 > 解决方案 > 在经典asp中导出到excel停止工作

问题描述

过去几天突然间,我们注意到导出到 excel 和 word 在经典的 asp 屏幕中不起作用。据我所知,代码没有问题。我认为这与 Microsoft 的某些安全更新或其他问题有关。谁能帮我解决这个问题

错误:

无法访问此站点

/Common/PtSchNoShowsExportToFile.asp?txtFromDt=12/08/2019&txtToDt=01/08/2020&appl=vnd.ms-excel&type=NoShow 的网页可能暂时关闭,或者它可能已永久移动到新的网址。

ERR_INVALID_RESPONSE

代码:

<%@ Language=VBScript %>
<%Response.expires = -1%>
<%
     'Change HTML header to specify Excel's MIME content type
     Response.Buffer = TRUE 
     Response.ContentType = "application/" & request("appl")

    dim filename
    filename = "No Show Report.xls"
    filename = Replace(filename, " ", "%20")
    Response.AddHeader "Content-Disposition", "attachment;filename="&filename

Function FormatDate(strDate)
        dim arrDate
        dim length
         
      if (strDate=null) then
          FormatDate=strDate
      else
          arrDate=Split(strDate,"/")
          length=UBound(arrDate)
          if(length>1) then
                if(len(arrDate(0))=1) then
                    arrDate(0)="0" + arrDate(0)
                end if
                if(len(arrDate(1))=1) then
                    arrDate(1)="0" + arrDate(1)
                end if
                FormatDate=arrDate(0) +"/" + arrDate(1) + "/" + arrDate(2)
           else
                FormatDate=strDate
            end if
       end if     
     
  End Function
%>
<HTML>
<body>
<% 
   '--Connection String
   set Cnn = server.CreateObject("ADODB.connection")
   Cnn.ConnectionString = Application("MyConnectionStringGoesHere")
   Cnn.open    

   set rs = Cnn.Execute("Sp_Report_ScheduleV4_NoShows @StartDate='" & request("txtFromDt") & "',@EndDate='" & request("txtToDt") & "'")

%>
<TABLE WIDTH = 75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR>
    <TD><font size=+2>Provider</TD>
    <TD><font size=+2>Date & Time</TD>
    <TD><font size=+2>Day</TD>
    <TD><font size=+2>Site</TD>
    <TD><font size=+2>Reason</TD>
    <TD><font size=+2>Chart</TD>
    <TD><font size=+2>Name</TD>
    <TD><font size=+2>Type</TD>
    <TD><font size=+2>Home#</TD>  
    <TD><font size=+2>work#</TD>    
    <TD><font size=+2>Cancel Reason</TD>
</TR>
<% Do while not rs.EOF %>
<TR>
    <TD><%=trim(rs("ProvName"))%></TD>
    <TD><%=FormatDate(rs("AppSDate"))%></TD>
    <TD><%=weekdayName(rs("DOW"),true)%></TD>
    <TD><%=trim(rs("LocCity"))%></TD>   
    <TD><%=rs("Reason")%></TD> 
    <TD><%=rs("pt_id")%></TD>   
    <TD><%=rs("ptName")%></TD>   
    <TD><%=rs("Type")%></TD>   
    <TD><%=rs("PtHomePhone")%></TD>   
    <TD><%=rs("PtWorkPhone")%></TD>   
    <TD><%=rs("CancelReason")%></TD>
</TR>
<%
        rs.MoveNext
   Loop
   rs.Close
   set rs = Nothing         
%>
</TABLE>
</BODY>
</HTML>

标签: excelvbscriptasp-classic

解决方案


推荐阅读