System.IO.TextWriter writer = new System.IO.StreamWriter(Server.MapPath("/provprice.xls"), false, System.Text.Encoding.GetEncoding("utf-8"));
writer.Write("<table cellspacing=\"3\" style=\"font-family:宋体\" cellpadding=\"5\" rules=\"all\" border=\"1\">");
writer.WriteLine("<tr style=\"font-weight:bold\"><td>");
writer.Write("供货商");
writer.Write("</td><td>");
writer.Write("商品");
writer.Write("</td><td>");
writer.Write("库存");
writer.Write("</td><td>");
writer.Write("价格");
writer.Write("</td><td>");
writer.Write("开始时间");
writer.Write("</td><td>");
writer.Write("结束时间");
writer.Write("</td>");
writer.WriteLine("</tr>");
///这里搜索要导出的数据信息(DataTable)
foreach (DataRow dr in dt.Rows)
{
writer.Write("<tr><td>");
writer.Write(dr["ProviderName"].ToString());
writer.Write("</td><td>");
writer.Write(dr["Name"].ToString());
writer.Write("</td><td>");
writer.Write(dr["Inventory"].ToString());
writer.Write("</td><td>");
writer.Write(dr["Prices"].ToString());
writer.Write("</td><td>");
writer.Write(dr["Begin_Time"].ToString());
writer.Write("</td><td>");
writer.Write(dr["End_Time"].ToString());
writer.Write("</td></tr>");
}
writer.Write("</table>");
writer.Close();
dt = null;