public void gdzc_to_excel()
{
string clmc = System.Web.HttpContext.Current.Server.UrlDecode(Request.QueryString["clmc"].ToString().Trim());
string ggxh = System.Web.HttpContext.Current.Server.UrlDecode(Request.QueryString["ggxh"].ToString().Trim());
string cfdd = System.Web.HttpContext.Current.Server.UrlDecode(Request.QueryString["cfdd"].ToString().Trim());
string zclx = System.Web.HttpContext.Current.Server.UrlDecode(Request.QueryString["zclx"].ToString().Trim());
Class1 c1 = new Class1("");
cmdtxt1 = " select * from qcjl where zclx like '%" + zclx + "%' and mc like '%" + clmc + "%' and ggxh like '%" + ggxh + "%' and cfdd like '%" + cfdd + "%' order by uptime1 desc ";
dt1 = c1.get_table(cmdtxt1);
StringBuilder sHtml = new StringBuilder(string.Empty);
sHtml.Append("<table border=\"1\" width=\"100%\">");
sHtml.Append("<tr height=\"40\"><td colspan=\"18\" align=\"center\" style='font-size:24px'><b>固定资产清查" + "</b></td></tr>");
//打印列名
sHtml.Append("<tr height=\"20\" align=\"center\" ><td>清查序号</td><td>资产编号</td><td>名称</td><td>规格型号</td><td>计量单位</td><td>数量</td><td>单价</td><td>金额</td><td>存放地点</td><td>存放架号</td><td>清查单位</td><td>生产日期</td><td>清查人</td><td>资产类型</td><td>库别</td><td>矿井名称</td><td>清查日期</td><td>备 注</td></tr>");
//循环读取List集合
for (int i = 0; i < dt1.Rows.Count; i++)
{
sHtml.Append("<tr height=\"20\" align=\"left\"><td>" + dt1.Rows[i]["qcxh"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["zcbh"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["mc"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["ggxh"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["jldw"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["sl"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["dj"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["je"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["cfdd"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["cfjh"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["qcdw"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["scrq"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["qcr"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["zclx"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["kb"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["kjmc"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["qcrq"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["bz"].ToString().Trim() + "</td></tr>");
}
sHtml.Append("</table>");
ExportToExcel("application/ms-excel", "固定资产清查.xls", sHtml.ToString());
{
System.Web.HttpContext.Current.Response.Charset = "UTF-8";
System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
System.Web.HttpContext.Current.Response.ContentType = FileType;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.HttpContext.Current.Response.Output.Write(ExcelContent.ToString());
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}
{
string clmc = System.Web.HttpContext.Current.Server.UrlDecode(Request.QueryString["clmc"].ToString().Trim());
string ggxh = System.Web.HttpContext.Current.Server.UrlDecode(Request.QueryString["ggxh"].ToString().Trim());
string cfdd = System.Web.HttpContext.Current.Server.UrlDecode(Request.QueryString["cfdd"].ToString().Trim());
string zclx = System.Web.HttpContext.Current.Server.UrlDecode(Request.QueryString["zclx"].ToString().Trim());
Class1 c1 = new Class1("");
cmdtxt1 = " select * from qcjl where zclx like '%" + zclx + "%' and mc like '%" + clmc + "%' and ggxh like '%" + ggxh + "%' and cfdd like '%" + cfdd + "%' order by uptime1 desc ";
dt1 = c1.get_table(cmdtxt1);
StringBuilder sHtml = new StringBuilder(string.Empty);
sHtml.Append("<table border=\"1\" width=\"100%\">");
sHtml.Append("<tr height=\"40\"><td colspan=\"18\" align=\"center\" style='font-size:24px'><b>固定资产清查" + "</b></td></tr>");
//打印列名
sHtml.Append("<tr height=\"20\" align=\"center\" ><td>清查序号</td><td>资产编号</td><td>名称</td><td>规格型号</td><td>计量单位</td><td>数量</td><td>单价</td><td>金额</td><td>存放地点</td><td>存放架号</td><td>清查单位</td><td>生产日期</td><td>清查人</td><td>资产类型</td><td>库别</td><td>矿井名称</td><td>清查日期</td><td>备 注</td></tr>");
//循环读取List集合
for (int i = 0; i < dt1.Rows.Count; i++)
{
sHtml.Append("<tr height=\"20\" align=\"left\"><td>" + dt1.Rows[i]["qcxh"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["zcbh"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["mc"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["ggxh"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["jldw"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["sl"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["dj"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["je"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["cfdd"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["cfjh"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["qcdw"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["scrq"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["qcr"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["zclx"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["kb"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["kjmc"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["qcrq"].ToString().Trim() + "</td><td>" + dt1.Rows[i]["bz"].ToString().Trim() + "</td></tr>");
}
sHtml.Append("</table>");
ExportToExcel("application/ms-excel", "固定资产清查.xls", sHtml.ToString());
}
{
System.Web.HttpContext.Current.Response.Charset = "UTF-8";
System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
System.Web.HttpContext.Current.Response.ContentType = FileType;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.HttpContext.Current.Response.Output.Write(ExcelContent.ToString());
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}