ASP.net中导出Excel表
来源:互联网 发布:sql查询200到300条记录 编辑:程序博客网 时间:2024/05/29 13:54
这是我做的一个消费记录的根据时间 类型的导出方法 带条件的导出 protected void btnExport_Click(object sender, EventArgs e) 设置表头 带条件的导出 Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName); Response.Write("<table border=1px>"); for (int i = 0; i < dt.Rows.Count; i++)
{
string shopid = Request.Cookies["shopid"].Value.ToString();
string beginTime = this.txtStartTime.Text;
string endTime = this.txtEndTime.Text;
string cardType = "";
if (this.DropDownList1.SelectedValue == "")
{
cardType = "";
}
else
{
if (this.DropDownList2.SelectedValue == "")
{
cardType = this.DropDownList1.SelectedValue;
}
else
{
cardType = this.DropDownList2.SelectedValue;
}
}
DataSet ds = new UserPayInfo_WT().UserPayInfoTongJi(shopid, beginTime, endTime, cardType);
DataTable dt = ds.Tables[0];
ExportToExcle(dt, "XiaoFeiJiLu.xls");
}
DataRow[] myRow = dt.Select("");
Response.Write(string.Format("<tr><td colspan='5' align='center'>开始时间:{0} 结束时间:{1} 卡类型:{2}; {3}销售汇总表</td></tr>",beginTime,endTime,cardType,shopName));
Response.Write("<tr><td>物品编码</td><td>物品名称</td><td>常用计量单位</td><td>数量</td><td>消费总额</td></tr>");
{
//Response.Write("<script>alert('" + dt.Columns.Count + "');</script>");
Response.Write("<tr>");
for (int j = 0; j < dt.Columns.Count; j++)
{
Response.Write("<td>" + dt.Rows[i][j].ToString() + "</td>");
}
Response.Write("</tr>");
}
Response.Write("</table>");
Response.Flush();
Response.End();
- 在ASP.NET中导出excel表
- ASP.net中导出Excel表
- ASP.net中导出Excel表
- ASP.net中导出Excel表
- Asp.net中Excel导出
- asp.net中导出excel
- Asp.NET 导出 Excel 或 Word中
- asp.net中Excel的导入导出
- Asp.net导出数据到Excel中
- asp.net gridview导出到Excel中。
- asp.net中datagrid导出excel
- ASP.NET导出数据到excel中
- ASP.NET中生成并导出Excel
- asp.net导出excel
- asp.net导出Excel
- asp.net导出excel
- asp.net导出Excel
- Asp.net 导出Excel
- 如何取消windows共享文件夹记住的密码
- php学习笔记(1)
- java 精度计算问题
- propotypy Ajax中的post提交
- 揭开正则表达式的神秘面纱
- ASP.net中导出Excel表
- 自己写的简易多任务系统---基于pic18fxxx
- 给文本框加上日历小图标(jquery-ui 中的小图标)
- ASP.net中导出Excel表
- 深入探索Win32结构化异常处理
- Asp.net2.0中的缓存机制
- BrewMP学习笔记
- 学习笔记(2)
- PKU 2289(网络最大流(SAP) + 二分枚举)