日期:2014-05-16  浏览次数:20460 次

如何把构建的table下载为 xlsx格式的excel
 string listId = con.Get("listId");
                    var sbHtml = new StringBuilder();
                    sbHtml.Append("<table border='1' cellspacing='0' cellpadding='0'>");
                    sbHtml.Append("<tr>");
                    var lstTitle = new List<string> { "电话", "楼盘名称", "户型", "数据类型", "时间" };
                    foreach (var item in lstTitle)
                    {
                        sbHtml.AppendFormat("<td style='font-size: 14px;text-align:center;background-color: #DCE0E2; font-weight:bold;' height='25'>{0}</td>", item);
                    }
                    sbHtml.Append("</tr>");
                    HouseDLL dll = new HouseDLL();
                    List<House> list = dll.ListHouse(listId);
                    if (list.Count > 0)
                    {
                        Message msg = new Message();
                        msg.Uid = u.Uid;
                        msg.Name = u.UserName;
                        msg.Content = u.UserName + "从户型表中导出了" + list.Count + "条数据";
                        msg.PostTime = DateTime.Now;
                        db.Message.Add(msg);
                        db.SaveChanges();
                    }
    &