コメント |
http://support.microsoft.com/default.aspx?scid=kb;ja;260519(@IMG01)
[[呼び出し : excel.asp?fname=format_00_week_report]]
@DIV
<%
Response.ContentType = "application/vnd.ms-excel"
Response.Addheader "Content-Disposition", "attachment; filename=" & Request.QueryString("fname") & ".xls"
Response.ExpiresAbsolute=#May 31,2000 23:59:59#
Set Stream = Server.CreateObject("ADODB.Stream")
Stream.Open
Stream.Type = 1 ' StreamTypeEnum の adTypeBinary
Stream.LoadFromFile Server.MapPath( Request.QueryString("fname") & ".xls" )
Response.BinaryWrite Stream.Read
Stream.Close
Set Stream = Nothing
%>
@END
@C:green(以下 HTTPヘッダ)
@DIV
HTTP/1.1 200 OK
Date: Thu, 08 Mar 2007 12:51:51 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
Content-Disposition: attachment; filename=format_00_week_report.xls
Content-Length: 32256
Content-Type: application/vnd.ms-excel
Expires: Wed, 31 May 2000 14:59:58 GMT
Cache-control: private
@END
↓PHP
@DIV
<?
header( "Content-Type: application/vnd.ms-excel" );
header( "Content-Disposition: " . "attachment; filename=" . $_GET["fname"] . ".xls" );
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" );
$data = @file_get_contents( $_GET["fname"] . ".xls" );
print $data;
?>
@END
|