webform 不实用office控件导出excel StringBuilder 类型拼接字符串表格导出excel

StringBuilder sb = new StringBuilder();

 sb.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">");

sb.AppendLine("<table border=\"1\">");
sb.Append("<tr><td>需要插入的内容,按个人需求</td></tr>");
sb.AppendLine("</table");

   //导出格式为xls并进行转码    name为保存excel的路径  
name="D:\aa\bb.xls";
StreamWriter sw = new StreamWriter(name,false,Encoding.GetEncoding("gb2312"));
 sw.WriteLine(sb.ToString());
sw.Close();



  

  

posted @ 2014-12-30 11:24  萧萧1949  阅读(501)  评论(2编辑  收藏  举报