C#web生成EXCEL文件

           Response.ClearContent();

            Response.AddHeader("content-disposition", "attachment;filename=test.xls");

            Response.ContentType = "application/excel";


            StringWriter swr = new StringWriter();
            for (int i = 0; i < 10; i++)
            {
                swr.WriteLine(string.Format("{0}\t3\twewe\tqeqwe\tewewqweqe",i));
            }
            HtmlTextWriter tw = new HtmlTextWriter(swr);

           

            Response.Write(swr.ToString());

            Response.End();

你可能感兴趣的:(C#web生成EXCEL文件)