private void HtmlResponseToExecl() { //将数据(html)导入到Excel中 Response.Charset = "gb2312"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); string filename = "../Execl/test"; //解决乱码问题 filename = HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8); Response.AddHeader("Content-Disposition", "attachment;filename=" + filename + ".xls"); Response.ContentType = "application/vnd.ms-excel"; Response.Write("<html><head><meta http-equiv=Content-Type content="text/html; charset=GB2312">"); Response.Write("<body>"); Response.Write("<table border=1px>"); //导入Excel表头信息 Response.Write("<tr style='background-color: gray;'><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>"); Response.Write("<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>"); Response.Write("<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>"); Response.Write("<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>"); Response.Write("<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>"); Response.Write("</table>"); Response.Write("</body></html>"); Response.Flush(); Response.End(); }