Thursday, June 05, 2008

OUTPUT FILE FROM THE BINARY STREAM WITH ASP.NET

OUTPUT FILE FROM THE BINARY STREAM WITH ASP.NET


Output File from binary stream with the asp.net

1. Output Excel File

Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Length", outputBytes.Length.ToString());
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.ContentType = "application/x-msexcel";
Response.BinaryWrite(outputBytes);
Response.End();

2. Output PDF

Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Length", outputBytes.Length.ToString());
Response.AddHeader("Content-Disposition", "filename=" + fileName);
Response.ContentType = "application/pdf";
Response.BinaryWrite(outputBytes);
Response.End();

0 comments: