/// <summary> /// 通用方法,通过开始字符串获取一个以字符串开始位置,此字符串右侧的的数据 /// </summary> public string getSpecifyString_NextColumn(DataTable dt, string findString, int[] underThisPoints, int[] overThisPoints = null) { //findString对应的位置 int[][] findString_Points; //findString_points的位置的对象 getDataTablePointsInfo findStringPoint; //判断有无结束位置 if (overThisPoints == null) { //获取findString_points位置 findStringPoint = new getDataTablePointsInfo(dt, underThisPoints); } else { //获取findString_points位置 findStringPoint = new getDataTablePointsInfo(dt, underThisPoints, overThisPoints); } findString_Points = findStringPoint.GetInfo_Between(findString); if (findString_Points == null) { //没有找到字符串 return(null); } int[] lastFindPoints = new int[] { findString_Points[0][0], findString_Points[0][1] + 1 }; //theDestString.Add(findStringPoint.GetInfo_Between(lastFindPoints)); return(findStringPoint.GetInfo_Between(lastFindPoints)); }
//判断是否有Customer report字段 public int[][] getCustomer_reportPoints(int[] underThisPoints, int[] overThisPoints = null) { string Customer_report = "Customer report"; int[][] findString_Points; //findString_points的位置 getDataTablePointsInfo findStringPoint; //判断有无结束位置 if (overThisPoints == null) { //获取findString_points位置 findStringPoint = new getDataTablePointsInfo(Resultdt, underThisPoints); } else { //获取findString_points位置 findStringPoint = new getDataTablePointsInfo(Resultdt, underThisPoints, overThisPoints); } findString_Points = findStringPoint.GetInfo_Between(Customer_report); if (findString_Points == null) { //没有找到字符串 MessageBox.Show("report Excel中没有产生任何报告!请检查确认"); return(null); } else { return(findString_Points); } }
//获取DataTable中某一string的位置 public int[] getPoints(DataTable dt, string findString) { getDataTablePointsInfo sectionInfo = new getDataTablePointsInfo(dt); int[][] Pannel_Points = sectionInfo.GetInfo_Between(findString); return(Pannel_Points[0]); }
/* * //获取Calculation results下的所有 Pattern 位置 * //Pattern1\Pattern2\Pattern3 Pattern格式 * public void getCalculationPatterns() * { * //获取的Pattern 字符,不是完全匹配 * string findString1 = "Pattern"; * * getDataTablePointsInfo sectionInfo = new getDataTablePointsInfo(dt, Calculation_Point, Machineconf_Point); * * calculation_Pattern_POints = sectionInfo.GetInfo_Between(findString1, false); * * } */ //获取Machine configration下的所有 Pattern 位置 //Pattern1\Pattern2\Pattern3 Pattern格式 public void getMachineconfPatterns() { //获取的Pattern 字符,不是完全匹配 string findString_Pattern = "Pattern"; getDataTablePointsInfo sectionInfo = new getDataTablePointsInfo(Resultdt, Machineconf_Point); machineconf_Pattern_POints = sectionInfo.GetInfo_Between(findString_Pattern, false); }
/// <summary> /// 通用方法,通过开始的字符串获取一个以字符串开始位置的一段DataTable区域 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public DataTable getCell_DT(string startString, int rowX, int columnY) { getDataTablePointsInfo sectionInfo = new getDataTablePointsInfo(Resultdt, startString); GetCellsDefined getCells = new GetCellsDefined(); getCells.GetCellArea(Resultdt, sectionInfo.StartPoint, rowX, columnY); return(getCells.DT); }
//获取区间三个位置点 "Pannel information" "Calculation results" "Machine configration' 的 位置 public void getPannelCalculationMachineconf_Point() { //获取 四个位置点 string findString_Panel = "Panel information"; string findString_JOB = "JOB"; string findString2 = "Calculation results"; string findString3 = "Machine configration"; getDataTablePointsInfo sectionInfo = new getDataTablePointsInfo(Resultdt); int[][] Pannel_Points = sectionInfo.GetInfo_Between(findString_Panel); int[][] Calculation_Points = sectionInfo.GetInfo_Between(findString2); int[][] Machineconf_Points = sectionInfo.GetInfo_Between(findString3); Pannel_Point = Pannel_Points[0]; Calculation_Point = Calculation_Points[0]; Machineconf_Point = Machineconf_Points[0]; JOB_Point = sectionInfo.GetInfo_Between(findString_JOB)[0]; }
/// <summary> /// 通用方法 重载,从underThisPoints位置开始,从overThisPoints位置之上,根据指定的字符串,获取此字符串下findN行的内容 /// </summary> /// <param name="findString"></param> /// <param name="underThisPoints"></param> /// <returns></returns> public string[] getSpecifyString_NextRow(string findString, int[] underThisPoints, int[] overThisPoints, int findN) { int[][] findString_Points; //findString_points的位置 getDataTablePointsInfo findStringPoint; //判断有无结束位置 if (overThisPoints == null) { //获取findString_points位置 findStringPoint = new getDataTablePointsInfo(Resultdt, underThisPoints); } else { //获取findString_points位置 findStringPoint = new getDataTablePointsInfo(Resultdt, underThisPoints, overThisPoints); } findString_Points = findStringPoint.GetInfo_Between(findString); if (findString_Points == null) { //没有找到字符串 return(null); } //获取findString_points位置下面findN行的内容 List <string> theDestString = new List <string>(); for (int i = 0; i < findN; i++) { int[] lastFindPoints = new int[] { findString_Points[0][0] + (i + 1), findString_Points[0][1] }; theDestString.Add(findStringPoint.GetInfo_Between(lastFindPoints)); } return(theDestString.ToArray()); }
//获取DataTable中两点间某一string的位置 public int[] getPoints(DataTable dt, int[] Point1, int[] Point2, string findString1) { getDataTablePointsInfo sectionInfo = new getDataTablePointsInfo(dt, Point1, Point2); return(sectionInfo.GetInfo_Between(findString1)[0]); }