asp.net webform download excel

1137 ワード

private void exportBinaryToExcel(byte[] bytes, string filename)

{

    Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);

    Response.AddHeader("Content-Length", bytes.Length.ToString());

    Response.ContentType = "application/octet-stream";

    Response.BinaryWrite(bytes);

    Response.Flush();

}