日期:2014-05-17 浏览次数:20559 次
DataTable ds = GetDataTable();
StringBuilder sbContent = new StringBuilder();
if (ds.Rows.Count > 0)
{
for (int i = 0; i < ds.Rows.Count; i++)
{
sbContent.Append("<tr style=\"height:30px\">");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + Convert.ToString(i + 1) + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_NAME"].ToString() + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_SEX"].ToString() + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_SFZ"].ToString() + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_ZZ"].ToString() + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_TEL"].ToString() + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_TEL2"].ToString() + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_SJ"].ToString() + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_RY"].ToString() + "</td>");
sbContent.Append("<td style='text-align:left;vnd.ms-excel.numberformat: @'>" + ds.Rows[i]["LR_BZ"].ToString() + "</td>");
sbContent.Append("</tr>");
}
}
StringBuilder sbHtml = new StringBuilder();
sbHtml.Append("<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" > ");
sbHtml.Append("<tr>");
sbHtml.Append("<th width=50 >序号</th>");
sbHtml.Append("<th width=100>姓名</th>");
sbHtml.Append("<th width=70 >性别</th>");
sbHtml.Append("<th width=200 >身份证号码</th>");
sbHtml.Append("<th width=200 >家庭住址</th>");
sbHtml.Append("<th width=200 >手机号码</th>");
sbHtml.Append("<th width=200 >固定电话</th>");
sbHtml.Append("<th width=200 >录入时间</th>");
sbHtml.Append("<th width=110 >录入人员</th>");
sbHtml.Append("<th width=200 >备注</th>");
sbHtml.Append("</tr>");
sbHtml.Append(sbContent);
sbContent.Append(" </table>");
sbHtml.Append("</table>");
Response.Clear();
Response.ContentType = "application nd.ms-excel";
Response.Charset = "gb2312";
Page.EnableViewState = false;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("客户录入名单") + DateTime.Now.ToString("yyyyMMddHHmmss&