日期:2014-05-18  浏览次数:20421 次

关于导出excel 自定换行问题
本人做了一个excel 导出, 是输出 html 直接导入excel ,导入进去,数据自动换行了,需求是不能换行,怎么做到
  sbHtml.Append("<td style=\"width:40px; text-align:center; vertical-align:middle;font-size:15px; font-weight: bold; height:49px;\">" + day + "</td>");

本人代码

------解决方案--------------------
把导出到Excel的代码给出来看看啊,

C# code

System.IO.StringWriter sw = new System.IO.StringWriter();
sw.Write("<td style=\"width:40px; text-align:center; vertical align:middle;font-size:15px; font-weight: bold; height:49px;\">" + 0 + "</td>");
sw.Close();

Response.Clear();
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("测试", System.Text.Encoding.UTF8) + DateTime.Now.ToShortDateString() + ".xls");
Response.ContentType = "application/ms-excel";
Response.Write(sw);
Response.End();