public void ExportDeliveryStatement()
        {
            string json = string.Empty;
            IlocQuery iloc = new IlocQuery();
            if (!System.IO.Directory.Exists(Server.MapPath(excelPath)))
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(excelPath));
            }
            DataTable dtHZ = new DataTable();
            string counts = Request.Params["counts"];
            string searchtype = Request.Params["searchtype"];//常溫或者冷凍
            string newExcelName = string.Empty;
            dtHZ.Columns.Add("主料位", typeof(String));
            dtHZ.Columns.Add("溫層", typeof(String));
            dtHZ.Columns.Add("品號", typeof(String));
            dtHZ.Columns.Add("品名", typeof(String));
            dtHZ.Columns.Add("規格", typeof(String));
            dtHZ.Columns.Add("廠商", typeof(String));
            dtHZ.Columns.Add("數量", typeof(String));
            dtHZ.Columns.Add("寄倉/調度", typeof(String));
            try
            {
                DataTable dt = new DataTable();
                _iasdMgr = new AseldMgr(mySqlConnectionString);
                dt = _iasdMgr.ExportDeliveryStatement(Convert.ToInt32(counts), Convert.ToInt32(searchtype));

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dtHZ.NewRow();
                    dr[0] = dt.Rows[i]["loc_id"];

                    if (Convert.ToInt32(dt.Rows[i]["export_id"]) == 2)
                    {
                        dr[1] = "常溫";
                    }
                    else if (Convert.ToInt32(dt.Rows[i]["export_id"]) == 92)
                    {
                        dr[1] = "冷凍";
                    }
                    else
                    {
                        dr[1] = "";
                    }
                    dr[2] = dt.Rows[i]["item_id"];
                    dr[3] = dt.Rows[i]["product_name"];

                    dr[4] = dt.Rows[i]["prod_sz"];
                    dr[5] = dt.Rows[i]["vendor_name_full"];

                    dr[6] = dt.Rows[i]["buy_num"];
                    if (dt.Rows[i]["product_mode"].ToString() == "2")
                    {
                        dr[7] = "寄倉";
                    }
                    else if (dt.Rows[i]["product_mode"].ToString() == "3")
                    {
                        dr[7] = "調度";
                    }
                    else
                    {
                        dr[7] = "";
                    }
                    dtHZ.Rows.Add(dr);
                }
                if (System.IO.File.Exists(newExcelName))
                {
                    System.IO.File.Delete(newExcelName);
                }
                string fileName = DateTime.Now.ToString("大出貨報表_yyyyMMddHHmm") + ".xls";
                MemoryStream ms = new MemoryStream();
                if (searchtype == "2")
                {
                    ms = ExcelHelperXhf.ExportDT(dtHZ, "常溫~大出貨報表_" + DateTime.Now.ToString("yyyyMMddHHmm"));
                }
                else
                {
                    ms = ExcelHelperXhf.ExportDT(dtHZ, "冷凍~大出貨報表_" + DateTime.Now.ToString("yyyyMMddHHmm"));
                }
                Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.BinaryWrite(ms.ToArray());
                //CsvHelper.ExportDataTableToCsv(dtHZ, newExcelName, colname, true);
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,data:[]}";
            }
        }