public void export() { this.Invoke(new EventHandler(delegate { btnDownload.Enabled = false; })); EXCEL.ExportToExcel(DtTable); this.Invoke(new EventHandler(delegate { btnDownload.Enabled = true; })); }
DataTable DtTable = new DataTable(); //创建空表 public void upLoad() { this.Invoke(new EventHandler(delegate { btnUpload.Enabled = false; })); progressBar_upload.Value = 0; //清空进度条 DtTable.Rows.Clear(); DtTable.Columns.Clear(); DataTable originDT = EXCEL.ImportFromExcel(this.txtFile.Text.Trim()); List <string> OrderIDList = new List <string>(); List <string> OrderTypeList = new List <string>(); int UsedRows = originDT.Rows.Count; string responseLock = string.Empty; JObject responseJsonEncry; string responseEncry = string.Empty; string responseDecry = string.Empty; string orderType = string.Empty; this.Invoke(new EventHandler(delegate { progressBar_upload.Maximum = UsedRows; })); for (int i = 1; i < UsedRows; i++) { this.Invoke(new EventHandler(delegate { progressBar_upload.Value = i + 1; })); OrderIDList.Add(originDT.Rows[i][0].ToString()); responseLock = MyTool.HttpUitls.getOrderIssue(OrderIDList[i - 1]); responseJsonEncry = JObject.Parse(responseLock); //string --> JObject responseEncry = responseJsonEncry["result"].ToString(); //取返回的加密Json数据里的result值 responseDecry = Decompress(responseEncry); //JObject-->string 解密result加密字符串,返回Json格式字符串 orderType = Regex.Match(responseDecry, "(?<=\"SaleType\":\")\\w+(?=\")").Value; Console.WriteLine(orderType); OrderTypeList.Add(orderType); Thread.Sleep(300); } //foreach (var item in OrderTypeList) //{ // Console.WriteLine(item); //} //DataColumn newDC = new DataColumn();//创建空列 //DtTable.Columns.Add(newDC);//空列加进空表 //DtTable.Columns.Add("订单号", typeof(String)); //DtTable.Columns.Add("订单来源", typeof(String)); DataColumn column1 = new DataColumn("订单号", typeof(String)); DataColumn column2 = new DataColumn("订单来源", typeof(String)); DtTable.Columns.Add(column1); DtTable.Columns.Add(column2); DataRow dr = DtTable.NewRow(); for (int i = 0; i < OrderIDList.Count; i++) { dr["订单号"] = OrderIDList[i]; dr["订单来源"] = OrderTypeList[i]; DtTable.Rows.Add(dr.ItemArray); } this.Invoke(new EventHandler(delegate { btnUpload.Enabled = true; })); }