From 1f9064d0d5ae5ed89800cc3603af3a47be646817 Mon Sep 17 00:00:00 2001 From: 王 垚 <1402714037@qq.com> Date: 星期一, 29 三月 2021 09:46:20 +0800 Subject: [PATCH] 文件上传改用npoi helper 类 --- src/BLL/Demo.BillView/PRD/Pro_ScDayImport.cs | 38 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/BLL/Demo.BillView/PRD/Pro_ScDayImport.cs b/src/BLL/Demo.BillView/PRD/Pro_ScDayImport.cs index b826ae9..d6e17d2 100644 --- a/src/BLL/Demo.BillView/PRD/Pro_ScDayImport.cs +++ b/src/BLL/Demo.BillView/PRD/Pro_ScDayImport.cs @@ -17,6 +17,7 @@ using System.Linq; using ZD.Share.Common; using ZD.Cloud.WebApi; +using Demo.Utility; namespace Demo.BillView.PRD { @@ -80,8 +81,13 @@ { if (!string.IsNullOrEmpty(fileFullPath)) { - DataSet ds = helper.ReadFromFile(fileFullPath, 1); + NpoiHelper np = new NpoiHelper(); + DataSet ds = np.ReadExcel(fileFullPath, 1); DataTable dt = ds.Tables[0]; + RemoveEmpty(dt);//鍘婚櫎绌鸿 + dt.Rows.RemoveAt(0);//鍘婚櫎鏍囬琛� + //DataSet ds = helper.ReadFromFile(fileFullPath, 1); + //DataTable dt = ds.Tables[0]; LogHelper.Info("瀵煎叆鍔熻兘锛歞t琛屾暟锛�" + dt.Rows.Count); DateTime date = Convert.ToDateTime(this.Model.GetValue("F_Paez_Date")); if (dt.Rows.Count > 0) @@ -374,7 +380,7 @@ Entry.Add(jsonFPOOrderEntry); } jsonModel.Add("FEntity", Entry); - jsonModel.Add("FID", Convert.ToString(current["FDayPlanID"])); + jsonModel.Add("FID", Convert.ToString(current["FDayPlanID"])); jsonRoot.Add("Model", jsonModel); var result = cloudClient.Save("Paez_Sc_WorkBillAutoSortBill", jsonRoot.ToString()); JObject saveObj = JObject.Parse(result); @@ -598,5 +604,33 @@ LogHelper.Error("鐢熶骇鏃ヨ鍒掑鍏ヨ褰曟棩蹇楄烦鍑�:" + ex.Message.ToString()); } } + + /// <summary> + /// dt鍘荤┖琛� + /// </summary> + /// <param name="dt"></param> + public void RemoveEmpty(DataTable dt) + { + List<DataRow> removelist = new List<DataRow>(); + for (int i = 0; i < dt.Rows.Count; i++) + { + bool IsNull = true; + for (int j = 0; j < dt.Columns.Count; j++) + { + if (!string.IsNullOrEmpty(dt.Rows[i][j].ToString().Trim())) + { + IsNull = false; + } + } + if (IsNull) + { + removelist.Add(dt.Rows[i]); + } + } + for (int i = 0; i < removelist.Count; i++) + { + dt.Rows.Remove(removelist[i]); + } + } } } -- Gitblit v1.9.1