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

时间:2021-03-09 15:26:55
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();

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