Beispiel #1
0
        private void btnCreateReport_Click(object sender, System.EventArgs e)
        {
            this.LoadParameters();
            DbQueryResult countDownList = PromoteHelper.ExprtAdOrderInfoList(new GroupBuyQuery
            {
                OrderId   = this.OrderId,
                starttime = this.StartTime.ToString(),
                endtime   = this.EndTime.ToString(),
                keyword   = this.KeyWord,
                PageIndex = this.pager.PageIndex,
                PageSize  = this.pager.PageSize,
                SortBy    = "Ordertime",
                SortOrder = SortAction.Desc
            });
            DataTable dtResult = (DataTable)countDownList.Data;

            if (dtResult == null || dtResult.Rows.Count == 0)
            {
                this.ShowMsg("没有数据!", false);
                return;
            }
            foreach (DataColumn cl in dtResult.Columns)
            {
                switch (cl.ColumnName.ToLower())
                {
                case "orderno":
                    cl.ColumnName = "订单号";
                    break;

                case "ordertotal":
                    cl.ColumnName = "订单总金额";
                    break;

                case "productname":
                    cl.ColumnName = "商品名称";
                    break;

                case "barcode":
                    cl.ColumnName = "商品条码";
                    break;

                case "sku":
                    cl.ColumnName = "Sku编码";
                    break;

                case "itemadjustedprice":
                    cl.ColumnName = "商品单价";
                    break;

                case "orderstatus":
                    cl.ColumnName = "订单状态";
                    break;

                case "paymenttype":
                    cl.ColumnName = "支付类型";
                    break;

                case "paymentstatus":
                    cl.ColumnName = "付款状态";
                    break;

                case "ordertime":
                    cl.ColumnName = "订单创建时间";
                    break;

                case "updatedate":
                    cl.ColumnName = "订单修改时间";
                    break;
                }
            }
            MemoryStream ms = NPOIExcelHelper.ExportToExcel(dtResult, "广告订单");

            this.Page.Response.Clear();
            this.Page.Response.Buffer  = false;
            this.Page.Response.Charset = "GB2312";

            this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=广告订单.xlsx");

            this.Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            this.Page.Response.ContentType     = "application/octet-stream";
            this.Page.EnableViewState          = false;
            this.Page.Response.BinaryWrite(ms.ToArray());
            ms.Dispose();
            ms.Close();
            EventLogs.WriteOperationLog(Privilege.ReconciOrdersDetailsExcel, string.Format(CultureInfo.InvariantCulture, "用户{0}广告订单导出明细成功", new object[]
            {
                this.User.Identity.Name
            }));

            this.Page.Response.End();
        }