private ExportExcel excel = new ExportExcel();
private int excelRows = 0;
private int excelColumns;
protected void ToExcel_Click(object sender, EventArgs e)
{
//Excel.ReportToExcel(rptList);
ExcelTitle();
InitExcelData();
}
private void ExcelTitle()
{
excel.RowStart();
excel.CellWithoutFormula("String", "订单号");
excel.CellWithoutFormula("String", "会员名");
excel.CellWithoutFormula("String", "总数量");
excel.CellWithoutFormula("String", "总金额");
excel.CellWithoutFormula("String", "总积分");
excel.CellWithoutFormula("String", "兑换状态");
excel.CellWithoutFormula("String", "备注");
excel.CellWithoutFormula("String", "下单时间");
excel.RowEnd();
excelRows++;
excelColumns = 8;
}
private void InitExcelData()
{
try
{
DataSet ds;
DataTable dt = new DataTable();
string startime = Request.Form["startime"];// this.startime.Text;
string endtime = Request.Form["endtime"]; //this.endtime.Text;
string str = "";
if (startime != "" || endtime != "")
{
str = "updateTime between '" + startime + "' and '" + endtime + "' order by id desc";
}
else
{
str = "";
}
ds = bllorder.GetList(str);
dt = ds.Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
excel.RowStart();
excel.CellWithoutFormula("String", dt.Rows[i]["order_num"].ToString());
excel.CellWithoutFormula("String", getUserName(Convert.ToInt32(dt.Rows[i]["user_id"].ToString())));
excel.CellWithoutFormula("String", dt.Rows[i]["quantity_sum"].ToString());
excel.CellWithoutFormula("String", Convert.ToDecimal(dt.Rows[i]["price_sum"]).ToString("0.00"));
excel.CellWithoutFormula("String", dt.Rows[i]["integral_sum"].ToString());
excel.CellWithoutFormula("String", getOrderStaute(dt.Rows[i]["order_status"].ToString()));
excel.CellWithoutFormula("String", dt.Rows[i]["note"].ToString());
excel.CellWithoutFormula("String", dt.Rows[i]["updateTime"].ToString());
excel.RowEnd();
excelRows++;
}
excel.CreateExcelWithMode(excelRows, excelColumns, DateTime.Now.ToShortDateString() + "-DBE积分兑换订单报表");
}
else
{
JscriptMsg("没有符合的数据信息!", "orderlist.aspx", "Error");
}
}
catch
{
}
}