输出Excel格式文件

 string msg = "ccccccccccccc";
        byte[] fileBuffer = new byte[8000];
        char[] ch = msg.ToCharArray();
        fileBuffer = System.Text.Encoding.Default.GetBytes(ch);
        Context.Response.ContentType = "application/vnd.ms-excel";
        Context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("hello.xls", System.Text.Encoding.UTF8));
        Context.Response.BinaryWrite(fileBuffer);
        Context.Response.End();
        Context.Response.Close(); 

posted on 2008-05-15 16:39  leanco  阅读(144)  评论(0)    收藏  举报

导航