org.hy.common.StringHelp Java Examples
The following examples show how to use
org.hy.common.StringHelp.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Job.java From hy.common.tpool with Apache License 2.0 | 6 votes |
/** * 设置:开始时间组。多个开始时间用分号分隔。多个开始时间对 "间隔类型:秒、分" 是无效的(只取最小时间为开始时间) * * @param i_StartTimesStr */ public void setStartTime(String i_StartTimesStr) { if ( Help.isNull(i_StartTimesStr) ) { return; } this.startTimes = new ArrayList<Date>(); String [] v_STimeArr = StringHelp.replaceAll(i_StartTimesStr ,new String[]{"\t" ,"\n" ,"\r"} ,new String[]{""}).split(","); for (String v_STime : v_STimeArr) { this.startTimes.add(new Date(v_STime.trim())); } Help.toSort(this.startTimes); }
Example #2
Source File: DatasMaker.java From hy.common.report with Apache License 2.0 | 6 votes |
public List<AppendComplex03> makeAppendComplex03() { List<AppendComplex03> v_Datas = new ArrayList<AppendComplex03>(); for (int i=1; i<=3; i++) { String v_No = StringHelp.lpad(i ,3 ,"0"); AppendComplex03 v_Data = new AppendComplex03(); v_Data.setQty( "Q" + v_No); v_Data.setTypeName("T" + v_No); v_Data.setRemark( "R" + v_No); v_Data.setLength( i); v_Data.setWidth( Help.multiply(i ,100)); v_Data.setHeight( Help.multiply(i ,60)); v_Data.setNet( Help.multiply(i ,10)); v_Data.setRt( Help.multiply(i ,30)); v_Data.setGross( Help.multiply(i ,Math.PI)); // 在模板上可设置显示的小数位数 v_Data.setQcode(XJava.getParam("QCodeImagePath").getValue() + i + ".png"); v_Datas.add(v_Data); } return v_Datas; }
Example #3
Source File: DatasMaker.java From hy.common.report with Apache License 2.0 | 6 votes |
public List<AppendComplex02> makeAppendComplex02() { List<AppendComplex02> v_Datas = new ArrayList<AppendComplex02>(); for (int i=1; i<=3; i++) { String v_No = StringHelp.lpad(i ,3 ,"0"); AppendComplex02 v_Data = new AppendComplex02(); v_Data.setNumber( "N" + v_No); v_Data.setEnglishName("E" + v_No); v_Data.setChineseName("C" + v_No); v_Data.setRetailNo( "R" + v_No); v_Data.setImageNo( "I" + v_No); v_Data.setSize( i); v_Datas.add(v_Data); } return v_Datas; }
Example #4
Source File: DatasMaker.java From hy.common.report with Apache License 2.0 | 6 votes |
public List<AppendComplex01> makeAppendComplex01() { List<AppendComplex01> v_Datas = new ArrayList<AppendComplex01>(); for (int i=1; i<=1; i++) { String v_No = StringHelp.lpad(i ,3 ,"0"); AppendComplex01 v_Data = new AppendComplex01(); v_Data.setNumber( "N" + v_No); v_Data.setType( "T" + v_No); v_Data.setChineseName("C" + v_No); v_Data.setName( "E" + v_No); v_Data.setSize( i); v_Datas.add(v_Data); } return v_Datas; }
Example #5
Source File: JU_ZXing.java From hy.common.report with Apache License 2.0 | 6 votes |
public List<ZXingData> getDatas(int i_DataSize) { List<ZXingData> v_Ret = new ArrayList<ZXingData>(); for (int i=0; i<i_DataSize; i++) { ZXingData v_Bean = new ZXingData(); v_Bean.setZxing2D(StringHelp.getUUID()); v_Bean.setZxing1D("" + (i * 314)); v_Ret.add(v_Bean); } return v_Ret; }
Example #6
Source File: JU_Help.java From hy.common.base with Apache License 2.0 | 6 votes |
public void test_replaceAll() { System.out.println("A'B".replaceAll("'" ,"''")); System.out.println(StringHelp.replaceAll("AAA.BBB.CC" ,"AAA" + "." ,"HY")); String v_Info = "\"electricConn\": \"NPT1/2\\\"\""; //System.out.println(v_Info + " = " + StringHelp.replaceAll(v_Info ,"\\\"" ,"\"")); System.out.println(v_Info + " = " + StringHelp.replaceAll(StringHelp.replaceAll(v_Info ,"\\\"" ,"\"") ,"\"" ,"\\\"")); System.out.println(StringHelp.replaceAll("AAA" ,"A" ,"B")); System.out.println(StringHelp.replaceAll("Q\"Q" ,"\"" ,"")); System.out.println(StringHelp.replaceAll("Q美元Q" ,"美元" ,"$")); System.out.println(StringHelp.replaceAll("Q美元Q" ,"美元" ,"")); System.out.println(StringHelp.replaceAll("Q美元Q" ,"" ,"$")); System.out.println(StringHelp.replaceAll("ABC" ,new String[]{"A" ,"B" ,"C"} ,new String[]{" "})); System.out.println(StringHelp.replaceAll("package com.fms.template.dao.impl;" ,new String[]{"template" ,"Template"} ,new String[]{"person" ,"Person"})); }
Example #7
Source File: ThreadPool.java From hy.common.tpool with Apache License 2.0 | 6 votes |
/** * 线程池详细信息 */ public static String showDetailInfo() { StringBuilder v_Buffer = new StringBuilder(); for (int i=0; i<THREADPOOL.size(); i++) { ThreadBase v_ThreadBase = THREADPOOL.get(i); v_Buffer.append(StringHelp.rpad(v_ThreadBase.getThreadNo() ,32 ," ")); v_Buffer.append(StringHelp.rpad(v_ThreadBase.getThreadRunStatus() ,16 ," ")); v_Buffer.append( v_ThreadBase.getExecuteTaskCount() ); v_Buffer.append("\n"); } return v_Buffer.toString(); }
Example #8
Source File: Job.java From hy.common.tpool with Apache License 2.0 | 6 votes |
/** * 设置:允许执行的条件。 * * 表达式中,预定义占位符有(占位符不区分大小写): * :Y 表示年份 * :M 表示月份 * :D 表示天 * :H 表示小时(24小时制) * :MI 表示分钟 * :S 表示秒 * :YMD 表示年月日,格式为YYYYMMDD 样式的整数类型。整数类型是为了方便比较 * * @param i_Condition */ public void setCondition(String i_Condition) { this.condition = Help.NVL(i_Condition).toUpperCase(); this.condition = StringHelp.replaceAll(this.condition ,new String[]{ ":" + $Condition_YMD ,":" + $Condition_S ,":" + $Condition_MI ,":" + $Condition_H ,":" + $Condition_D ,":" + $Condition_D ,":" + $Condition_Y } ,new String[]{ $Condition_YMD ,$Condition_S ,$Condition_MI ,$Condition_H ,$Condition_D ,$Condition_M ,$Condition_Y }); }
Example #9
Source File: JU_Round.java From hy.common.base with Apache License 2.0 | 5 votes |
public static void main(String [] args) { int v_Digit = 2; BigDecimal v_Base = new BigDecimal(1d); BigDecimal v_Plus = new BigDecimal(0.001d); for (int i=1; i<=1000 * 100; i++) { v_Base = v_Base.add(v_Plus); double v_R01 = Help.round(v_Base.doubleValue() ,v_Digit); // 对比Java自身提供的四舍五入方法 double v_R02 = new BigDecimal(v_Base.doubleValue()).setScale(v_Digit ,BigDecimal.ROUND_HALF_UP).doubleValue(); System.out.print(StringHelp.rpad(String.valueOf(v_Base.doubleValue()) ,20 ," ") + " ~ " + StringHelp.rpad(String.valueOf(v_R01) ,10 ," ") + " BigDecimal: " + String.valueOf(v_R02)); if ( v_R01 != v_R02 ) { System.out.println(" *********************"); } else { System.out.println(""); } } }
Example #10
Source File: Job.java From hy.common.tpool with Apache License 2.0 | 5 votes |
/** * 设置:云计算服务器的地址端口。格式为:IP:Port。 * * 默认端口是:1721 * * @param i_CloudServer */ public void setCloudServer(String i_CloudServer) { if ( Help.isNull(i_CloudServer) ) { this.cloudSocket = null; this.cloudServer = null; return; } this.cloudServer = StringHelp.replaceAll(i_CloudServer ,new String[]{"," ," " ,"\t" ,"\r" ,"\n"} ,new String[]{"," ,""}); String [] v_HostPort = (this.cloudServer.trim() + ":1721").split(":"); this.cloudSocket = new ClientSocket(v_HostPort[0] ,Integer.parseInt(v_HostPort[1])); }
Example #11
Source File: JU_PageTitle.java From hy.common.report with Apache License 2.0 | 5 votes |
public List<OrgInfo> getDatas(int i_OrgSize) { List<OrgInfo> v_Orgs = new ArrayList<OrgInfo>(); for (int i=1; i<=i_OrgSize; i++) { OrgInfo v_Org = new OrgInfo(); v_Org.setOrgNo(StringHelp.lpad(i ,3 ,"0")); v_Org.setOrgName("部门名称 " + i); for (int x=1; x<=i*2; x++) { StaffInfo v_Staff = new StaffInfo(); v_Staff.setStaffNo(v_Org.getOrgNo() + "-" + StringHelp.lpad(x ,3 ,"0")); v_Staff.setStaffName("员工名称 " + x); v_Staff.setTime(new Date()); v_Org.getStaffs() .add(v_Staff); v_Org.getStaffSet().add(v_Staff); v_Org.getStaffMap().put(v_Staff.getStaffNo() ,v_Staff); } v_Orgs.add(v_Org); } return v_Orgs; }
Example #12
Source File: JU_Total_Subtotal.java From hy.common.report with Apache License 2.0 | 5 votes |
public List<OrgInfo> getDatas(int i_OrgSize) { List<OrgInfo> v_Orgs = new ArrayList<OrgInfo>(); for (int i=1; i<=i_OrgSize; i++) { OrgInfo v_Org = new OrgInfo(); v_Org.setOrgNo(StringHelp.lpad(i ,3 ,"0")); v_Org.setOrgName("部门名称 " + i); for (int x=1; x<=i*2; x++) { StaffInfo v_Staff = new StaffInfo(); v_Staff.setStaffNo(v_Org.getOrgNo() + "-" + StringHelp.lpad(x ,3 ,"0")); v_Staff.setStaffName("员工名称 " + x); v_Staff.setTime(new Date()); v_Org.getStaffs() .add(v_Staff); v_Org.getStaffSet().add(v_Staff); v_Org.getStaffMap().put(v_Staff.getStaffNo() ,v_Staff); } v_Orgs.add(v_Org); } return v_Orgs; }
Example #13
Source File: JU_ReportNormal.java From hy.common.report with Apache License 2.0 | 5 votes |
public List<OrgInfo> getDatas(int i_OrgSize) { List<OrgInfo> v_Orgs = new ArrayList<OrgInfo>(); for (int i=1; i<=i_OrgSize; i++) { OrgInfo v_Org = new OrgInfo(); v_Org.setOrgNo(StringHelp.lpad(i ,3 ,"0")); v_Org.setOrgName("部门名称 1234567890中国qwertyuiop美国asdfghjkl英国zxcvbnm" + i); for (int x=1; x<=i*2; x++) { StaffInfo v_Staff = new StaffInfo(); v_Staff.setStaffNo(v_Org.getOrgNo() + "-" + StringHelp.lpad(x ,3 ,"0")); v_Staff.setStaffName("员工名称 " + x); v_Staff.setTime(new Date()); v_Org.getStaffs() .add(v_Staff); v_Org.getStaffSet().add(v_Staff); v_Org.getStaffMap().put(v_Staff.getStaffNo() ,v_Staff); } v_Orgs.add(v_Org); } return v_Orgs; }
Example #14
Source File: ExcelFormula.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 将Excel单元格ID,转换为Java语言标识的行号、列号。 * * 如,将A1翻译为,第1列第1行,实际返回 0,0 ,下标均从0开始 * * @author ZhengWei(HY) * @createDate 2020-05-19 * @version v1.0 * * @param i_CellExcelID Excel单元格ID,如1 * @return */ public static RCell cellIDtoJava(String i_CellExcelID) { if ( Help.isNull(i_CellExcelID) ) { return null; } String [] v_CEIDArr = i_CellExcelID.split("!"); String v_CEID = v_CEIDArr[v_CEIDArr.length - 1]; String v_CellExcelID = StringHelp.replaceAll(v_CEID.trim().toUpperCase() ,"$" ,""); String v_RowName = StringHelp.replaceAll(v_CellExcelID ,$A_TO_Z ,new String [] {""}); if ( Help.isNull(v_RowName) || !Help.isNumber(v_RowName) || StringHelp.isContains(v_RowName ,"." ,"-" ," ") ) { return null; } int v_RowNo = Integer.parseInt(v_RowName); String v_ColName = StringHelp.replaceAll(v_CellExcelID ,v_RowNo + "" ,""); if ( v_ColName.length() <= 0 || v_ColName.length() > 3 ) { return null; } RCell v_Ret = new RCell(); v_Ret.setRowNo( v_RowNo - 1); v_Ret.setColNo(StringHelp.reABC26(v_ColName)); v_Ret.setFixedRow(v_CEID.trim().indexOf("$") > 0); v_Ret.setFixedCol(v_CEID.trim().startsWith("$")); return v_Ret; }
Example #15
Source File: ExcelFormula.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 计算单元格在偏移量(偏移多少行、偏移多少列)后新的单元格ID * * 如,A1偏移1行为:A2 * 如,A1偏移1列为:B1 * * @author ZhengWei(HY) * @createDate 2020-05-20 * @version v1.0 * * @param i_CellExcelID 单元格的ID。为Excel与人交互的ID,如,A1表示第1列的第1行坐标位置上单元格。 * @param i_OffsetRow 偏移多少行。零值,表示不偏移;负值向i_CellExcelID上方偏移;正值向i_CellExcelID下方偏移。 * @param i_OffsetCol 偏移多少列。零值,表示不偏移;负值向i_CellExcelID左方偏移;正值向i_CellExcelID右方偏移。 * @return */ public static String calcCellOffset(String i_CellExcelID ,int i_OffsetRow ,int i_OffsetCol) { if ( Help.isNull(i_CellExcelID) ) { return i_CellExcelID; } if ( StringHelp.getCount(i_CellExcelID ,"\\$") >= 2 ) { // 绝对行、绝对列是不能偏移的。 return i_CellExcelID; } RCell v_RCell = cellIDtoJava(i_CellExcelID); if ( v_RCell == null ) { return i_CellExcelID; } if ( !v_RCell.isFixedRow() ) { v_RCell.setRowNo(Help.max(v_RCell.getRowNo() + i_OffsetRow ,0)); } if ( !v_RCell.isFixedCol() ) { v_RCell.setColNo(Help.max(v_RCell.getColNo() + i_OffsetCol ,0)); } return cellIDtoExcel(v_RCell); }
Example #16
Source File: ExcelFormula.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 解释公式,将公式中的单元格ID独立提取出来。 * * 1. 会去除重复的单元格ID * 2. 会去除绝对行、绝对列定位的单元格ID * 3. 保留只绝对行 或 只绝对列定位的单格ID,去除绝对行及绝对列的单元格ID * * @author ZhengWei(HY) * @createDate 2020-05-20 * @version v1.0 * * @param i_Formula Excle公式 * @return */ public static String [] parserFormula(String i_Formula) { if ( Help.isNull(i_Formula) ) { return new String[0]; } String v_CellIDs = ""; v_CellIDs = StringHelp.trim(i_Formula.trim().toUpperCase()); v_CellIDs = StringHelp.replaceAll(v_CellIDs ,$Formulas ,new String[] {$ParserFormulaSplit}); v_CellIDs = StringHelp.trimToDistinct(v_CellIDs ,$ParserFormulaSplit); String [] v_CellIDArr = v_CellIDs.split($ParserFormulaSplit); if ( Help.isNull(v_CellIDArr) ) { return new String[0]; } List<String> v_CellIDList = Help.toDistinct(v_CellIDArr); for (int i=v_CellIDList.size()-1; i>=0; i--) { if ( Help.isNull(v_CellIDList.get(i)) ) { // 去除空 v_CellIDList.remove(i); } else if ( StringHelp.getCount(v_CellIDList.get(i) ,"\\$") >= 2 ) { // 去除绝对行、绝对列定位的单元格ID v_CellIDList.remove(i); } } if ( Help.isNull(v_CellIDList) ) { return new String[0]; } return v_CellIDList.toArray(new String[] {}); }
Example #17
Source File: ExcelFormula.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 计算Excel公式在偏移量(偏移多少行、偏移多少列)后新的Excel公式。 * * Excel公式中涉及到的所有单元格ID均将偏移。 * * 如,= A1 + B1 偏移1行为: = A2 + B2 * 如,= $A1 + B1 偏移1列为: = $A1 + C1 * 如,= $A$1 + B1 偏移1行1列为:= $A$1 + C2 * * @author ZhengWei(HY) * @createDate 2020-05-21 * @version v1.0 * * @param i_Formula Excle公式。 * @param i_OffsetRow 偏移多少行。零值,表示不偏移;负值向i_CellExcelID上方偏移;正值向i_CellExcelID下方偏移。 * @param i_OffsetCol 偏移多少列。零值,表示不偏移;负值向i_CellExcelID左方偏移;正值向i_CellExcelID右方偏移。 * @return */ public static String calcFormulaOffset(String i_Formula ,int i_OffsetRow ,int i_OffsetCol) { if ( Help.isNull(i_Formula) ) { return i_Formula; } String v_Formula = i_Formula.trim().toUpperCase(); String [] v_CellExcelIDOld = parserFormula(v_Formula); if ( Help.isNull(v_CellExcelIDOld) ) { return i_Formula; } String [] v_CellExcelIDPK = new String[v_CellExcelIDOld.length]; // 防止多次替换时的误替换 String [] v_CellExcelIDNew = new String[v_CellExcelIDOld.length]; // 偏移后的单元格ID for (int i=0; i<v_CellExcelIDOld.length; i++) { if ( v_CellExcelIDOld[i].startsWith("$") ) { v_CellExcelIDPK[i] = v_CellExcelIDOld[i].substring(0 ,2) + $ParserFormulaSplit + v_CellExcelIDOld[i].substring(2); } else { v_CellExcelIDPK[i] = v_CellExcelIDOld[i].substring(0 ,1) + $ParserFormulaSplit + v_CellExcelIDOld[i].substring(1); } v_CellExcelIDNew[i] = calcCellOffset(v_CellExcelIDOld[i] ,i_OffsetRow ,i_OffsetCol); } v_Formula = StringHelp.replaceAll(v_Formula ,v_CellExcelIDOld ,v_CellExcelIDPK); v_Formula = StringHelp.replaceAll(v_Formula ,v_CellExcelIDPK ,v_CellExcelIDNew); return v_Formula; }
Example #18
Source File: EnCode.java From hy.common.base with Apache License 2.0 | 5 votes |
public static void main(String [] i_Args) { AppParameter v_AppParams = new AppParameter(i_Args); if ( !v_AppParams.isExists("code") ) { System.out.println("not find code."); return; } for (String v_Arg : i_Args) { if ( v_Arg.indexOf("=") >= 0 ) { String [] v_Params = v_Arg.split("="); if ( v_Params.length >= 2 && "code".equalsIgnoreCase(v_Params[0]) ) { StringBuilder v_Buffer = new StringBuilder(); for (int i=1; i<v_Params.length; i++) { v_Buffer.append(v_Params[i]); } System.out.println(StringHelp.toCode(v_Buffer.toString() ,1)); } } } }
Example #19
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_toCode() { System.out.println(StringHelp.toCode("12" ,4)); System.out.println(StringHelp.toCode(StringHelp.toCode("12" ,4) ,4)); System.out.println(StringHelp.toCode("1234567890-=`~!@#$%^&*()_+[]{};:'\",./<>?" ,8)); System.out.println(StringHelp.toCode(StringHelp.toCode("1234567890-=`~!@#$%^&*()_+[]{};:'\",./<>?" ,8) ,8)); }
Example #20
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_toABC36() { for (int i=0; i<=100; i++) { System.out.println(i + " = " + StringHelp.toABC36(i) + " \t反向 = " + StringHelp.reABC36(StringHelp.toABC36(i))); } }
Example #21
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_toABC26() { for (int i=0; i<=100; i++) { System.out.println(i + " = " + StringHelp.toABC26(i) + " \t反向 = " + StringHelp.reABC26(StringHelp.toABC26(i))); } }
Example #22
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_getCharEncoding() { String v_Text = "我爱"; System.out.println(StringHelp.getCharEncodings(v_Text)); String v_GBK = StringHelp.toCharEncoding(v_Text ,"UTF-8" ,"GBK"); String v_ISO_8859_1 = StringHelp.toCharEncoding(v_Text ,"UTF-8" ,"ISO-8859-1"); System.out.println(StringHelp.getCharEncodings(v_GBK)); System.out.println(StringHelp.getCharEncodings(v_ISO_8859_1)); }
Example #23
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_replaceFirst() { System.out.println("非首位时:" + StringHelp.replaceFirst("#$%_ABC_123_ABC_456_ABC_789" ,"ABC" ,"XYZ")); System.out.println("在首位时:" + StringHelp.replaceFirst("ABC_123_ABC_456_ABC_789" ,"ABC" ,"XYZ")); System.out.println("在末尾时:" + StringHelp.replaceFirst("#$%_123_ABC" ,"ABC" ,"XYZ")); }
Example #24
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_replaceLast() { System.out.println("非末尾时:" + StringHelp.replaceLast("#$%_ABC_123_ABC_456_ABC_789" ,"ABC" ,"XYZ")); System.out.println("在末尾时:" + StringHelp.replaceLast("#$%_ABC_123_ABC" ,"ABC" ,"XYZ")); System.out.println("在首位时:" + StringHelp.replaceLast("ABC_123_#$%" ,"ABC" ,"XYZ")); }
Example #25
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_md5() { System.out.println(StringHelp.md5("xsso")); System.out.println(StringHelp.md5("xsso" ,StringHelp.$MD5_Type_Hex)); System.out.println(StringHelp.md5("getData=;getDataType=1D;getDeviceNo=867246023785125;getDeviceType=android;" + "@20170801")); System.out.println("yGSajQF/npSzjy179WP01Q__"); }
Example #26
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_encode() { String v_Charset = "UTF-8"; System.out.println(StringHelp.encode("ABCDEFG hiklmn 1234567890 `~!@#$%^&*()-_=+[]{},./<>?;':\"" ,v_Charset ,"=&?")); System.out.println(StringHelp.decode(StringHelp.encode("ABCDEFG hiklmn 1234567890 `~!@#$%^&*()-_=+[]{},./<>?;':\"" ,v_Charset ,"=&?") ,v_Charset)); System.out.println(StringHelp.decode(StringHelp.encode("中华人民共和国" ,v_Charset ,"=&?") ,v_Charset)); }
Example #27
Source File: JU_StringHelp.java From hy.common.base with Apache License 2.0 | 5 votes |
@Test public void test_toNumberSimplify() { System.out.println(StringHelp.toNumberSimplify("1234567890.1" ,6 ,2)); System.out.println(StringHelp.toNumberSimplify("1.2345678" ,6 ,2)); System.out.println(StringHelp.toNumberSimplify("1234.5678" ,6 ,2)); System.out.println(StringHelp.toNumberSimplify("0.000001" ,6 ,2)); }
Example #28
Source File: ExcelHelp.java From hy.common.report with Apache License 2.0 | 4 votes |
/** * 复制模板工作表的打印区域到数据工作表中 * 1. 精确定位复杂报表(标题不是在同一行或多行,而是标题与数据相互交融显示)的打印区域 * 2. 确保同一Excel在不同电脑上打印分页是一样(但不保证打印DPI,即行高是一样的) * * @author ZhengWei(HY) * @createDate 2020-05-11 * @version v1.0 * * @param i_FromSheet 源工作表 * @param i_ToSheet 目标工作表 * @param i_ToSheetLastRowNum 目标工作表原用的数据。下标从0开始,0表示目标工作表还未写入任何数据 * @param i_NewDataSize 本次数据(或追加数据)的大小,即分页页数 */ public final static void copyPrintSetup(Sheet i_FromSheet ,Sheet i_ToSheet ,int i_ToSheetLastRowNum ,int i_NewDataSize) { int v_FromSheetIndex = i_FromSheet.getWorkbook().getSheetIndex(i_FromSheet); int v_ToSheetIndex = i_ToSheet .getWorkbook().getSheetIndex(i_ToSheet); String v_FromSheetName = i_FromSheet.getWorkbook().getSheetName(v_FromSheetIndex); String v_ToSheetName = i_ToSheet .getWorkbook().getSheetName(v_ToSheetIndex); String v_FromPrintArea = i_FromSheet.getWorkbook().getPrintArea(v_FromSheetIndex); String v_ToPrintArea = i_ToSheet .getWorkbook().getPrintArea(v_ToSheetIndex); if ( Help.isNull(v_FromPrintArea) || i_NewDataSize <= 0 ) { return; } String [] v_RepalceSpace = {""}; StringBuilder v_ToPrintAreaBuffer = new StringBuilder(); v_FromPrintArea = StringHelp.replaceAll(v_FromPrintArea ,new String[] {v_FromSheetName + "!" ,"$"} ,v_RepalceSpace); if ( !Help.isNull(v_ToPrintArea) ) { v_ToPrintArea = StringHelp.replaceAll(v_ToPrintArea ,new String[] {v_ToSheetName + "!" ,"$"} ,v_RepalceSpace); v_ToPrintAreaBuffer.append(v_ToPrintArea).append(","); } String [] v_SEArr = v_FromPrintArea.split(":"); int v_StartRow = ExcelFormula.cellIDtoJava(v_SEArr[0]).getRowNo() + 1; int v_EndRow = ExcelFormula.cellIDtoJava(v_SEArr[1]).getRowNo() + 1; int v_PageRowSize = v_EndRow - v_StartRow + 1; String v_StartColumn = StringHelp.replaceAll(v_SEArr[0] ,v_StartRow + "" ,""); String v_EndColumn = StringHelp.replaceAll(v_SEArr[1] ,v_EndRow + "" ,""); v_StartRow += i_ToSheetLastRowNum; v_EndRow += i_ToSheetLastRowNum; for (int v_PageNo=1; v_PageNo<=i_NewDataSize; v_PageNo++) { v_ToPrintAreaBuffer.append(v_StartColumn).append(v_StartRow + v_PageRowSize * (v_PageNo - 1)); v_ToPrintAreaBuffer.append(":"); v_ToPrintAreaBuffer.append(v_EndColumn) .append(v_EndRow + v_PageRowSize * (v_PageNo - 1)); if ( v_PageNo < i_NewDataSize ) { v_ToPrintAreaBuffer.append(","); } } // 设置对应工作表的打印区域 i_ToSheet.getWorkbook().setPrintArea(v_ToSheetIndex ,v_ToPrintAreaBuffer.toString()); }
Example #29
Source File: MethodFieldComparator.java From hy.common.base with Apache License 2.0 | 4 votes |
/** * 查询与方法名称一样(不区分大小写)的成员属性的位置 * * @author ZhengWei(HY) * @createDate 2018-04-25 * @version v1.0 * * @param i_Method * @return 返回 -1 表示:没有找到 */ private int findFieldIndex(Method i_Method) { String v_MethodName = i_Method.getName(); int v_Index = -1; // getter if ( i_Method.getParameterTypes().length <= 0 ) { if ( v_MethodName.startsWith("get") ) { v_Index = this.findFieldIndex(StringHelp.toLowerCaseByFirst(v_MethodName.substring(3))); } else if ( v_MethodName.startsWith("is") ) { v_Index = this.findFieldIndex(v_MethodName); if ( v_Index < 0 ) { v_Index = this.findFieldIndex(StringHelp.toLowerCaseByFirst(v_MethodName.substring(2))); } } else { v_Index = this.findFieldIndex(v_MethodName); } } // setter else { if ( v_MethodName.startsWith("set") ) { v_Index = this.findFieldIndex(StringHelp.toLowerCaseByFirst(v_MethodName.substring(3))); } else { v_Index = this.findFieldIndex(v_MethodName); } } return v_Index; }
Example #30
Source File: JU_Help.java From hy.common.base with Apache License 2.0 | 4 votes |
@Test public void test_getUUIDLong() { System.out.println(StringHelp.getUUIDNum()); }