diff --git a/src/main/java/com/wb/excel/api/enumeration/Status.java b/src/main/java/com/wb/excel/api/enumeration/Status.java deleted file mode 100644 index 9623c52..0000000 --- a/src/main/java/com/wb/excel/api/enumeration/Status.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.wb.excel.api.enumeration; - -/** - * Created on 2014/9/23. - * - * @author - * @version v1.0.0.0 - */ -public enum Status { - /** - * 数据库中已存在 - */ - EXIST, - /** - * 数据库中不存在 - */ - NOTEXIST, - /** - * 不符合的枚举值 - */ - ERROR_VALUE, - /** - * 验证通过 - */ - PASS, - /** - * 不允许重复的列发生了重复 - */ - REPEAT, - /** - * 格式不正确 - */ - FORMAT, - /** - * 长度不符合要求 - */ - LENGTH, - /** - * 不允许为空的列出现了空 - */ - EMPTY, - /** - * 数字类型的值过小 - */ - TOO_SMALL, - /** - * 数字类型的值过大 - */ - TOO_BIG -} diff --git a/src/main/java/com/wb/excel/api/exception/ColumnNameNotExistException.java b/src/main/java/com/wb/excel/api/exception/ColumnNameNotExistException.java deleted file mode 100644 index 01c004f..0000000 --- a/src/main/java/com/wb/excel/api/exception/ColumnNameNotExistException.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.wb.excel.api.exception; - -/** - * Created on 2014/10/12. - * - * @author - * @version 0.1.0 - */ -public class ColumnNameNotExistException extends RuntimeException { - private static final long serialVersionUID = 234122996006212387L; - - /** - * Constructs a new runtime exception with {@code null} as its - * detail message. The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause}. - */ - public ColumnNameNotExistException() { - super(); - } - - /** - * Constructs a new runtime exception with the specified detail message. - * The cause is not initialized, and may subsequently be initialized by a - * call to {@link #initCause}. - * - * @param message the detail message. The detail message is saved for - * later retrieval by the {@link #getMessage()} method. - */ - public ColumnNameNotExistException(String message) { - super(message); - } -} diff --git a/src/main/java/com/wb/excel/api/exception/Error.java b/src/main/java/com/wb/excel/api/exception/Error.java deleted file mode 100644 index ee1dd24..0000000 --- a/src/main/java/com/wb/excel/api/exception/Error.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.wb.excel.api.exception; - -import java.io.Serializable; - -public class Error implements Serializable { - - private static final long serialVersionUID = 3L; - - private String code; - - private ErrorType type; - - private String message; - - public Error() { - } - - public Error(String code, String message) { - this.code = code; - this.message = message; - } - - public Error(ErrorType type, String message) { - this.type = type; - this.code = type.toString(); - this.message = message; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public ErrorType getType() { - return type; - } - - public void setType(ErrorType type) { - this.type = type; - } -} diff --git a/src/main/java/com/wb/excel/api/exception/ErrorType.java b/src/main/java/com/wb/excel/api/exception/ErrorType.java deleted file mode 100644 index ca0cad6..0000000 --- a/src/main/java/com/wb/excel/api/exception/ErrorType.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.wb.excel.api.exception; - -/** - * Created on 2014/10/15. - * - * @author - * @version 0.1.0 - */ -public class ErrorType { - /** - * 唯一性错误,出现了不允许重复的内容 - */ - public static String UNIQUENESS_ERROR = "UNIQUENESS_ERROR"; - /** - * 期待值为空 找不到想要的对象 - */ - public static String EXPECTATION_NULL = "EXPECTATION_NULL"; - /** - * 业务错误 不符合业务逻辑的情况发生 - */ - public static String BUSINESS_ERROR = "BUSINESS_ERROR"; - /** - * 系统错误 JDBC的错误等 - */ - public static String SYSTEM_ERROR = "SYSTEM_ERROR"; - /** - * 非法的参数 无效,格式不对、非法值、越界等 - */ - public static String INVALID_PARAMETER = "INVALID_PARAMETER"; - /** - * 其它未归类错误 - */ - public static String OTHER = "OTHER"; - /** - * 异常信息Dump - */ - public static String STACK_DUMP = "STACK_DUMP"; -} diff --git a/src/main/java/com/wb/excel/api/exception/ExistedColumnNameException.java b/src/main/java/com/wb/excel/api/exception/ExistedColumnNameException.java deleted file mode 100644 index 1c62a8c..0000000 --- a/src/main/java/com/wb/excel/api/exception/ExistedColumnNameException.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.wb.excel.api.exception; - -/** - * Created on 2014/10/12. - * - * @author - * @version 0.1.0 - */ -public class ExistedColumnNameException extends RuntimeException { - private static final long serialVersionUID = 234122996006212387L; - - /** - * Constructs a new runtime exception with {@code null} as its - * detail message. The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause}. - */ - public ExistedColumnNameException() { - super(); - } - - /** - * Constructs a new runtime exception with the specified detail message. - * The cause is not initialized, and may subsequently be initialized by a - * call to {@link #initCause}. - * - * @param message the detail message. The detail message is saved for - * later retrieval by the {@link #getMessage()} method. - */ - public ExistedColumnNameException(String message) { - super(message); - } -} diff --git a/src/main/java/com/wb/excel/api/exception/IllegalParameterException.java b/src/main/java/com/wb/excel/api/exception/IllegalParameterException.java deleted file mode 100644 index e9907b2..0000000 --- a/src/main/java/com/wb/excel/api/exception/IllegalParameterException.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.wb.excel.api.exception; - -/** - * Created on 2014/10/12. - * - * @author - * @version 0.1.0 - */ -public class IllegalParameterException extends RuntimeException { - private static final long serialVersionUID = 234122996006212387L; - - /** - * Constructs a new runtime exception with {@code null} as its - * detail message. The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause}. - */ - public IllegalParameterException() { - super(); - } - - /** - * Constructs a new runtime exception with the specified detail message. - * The cause is not initialized, and may subsequently be initialized by a - * call to {@link #initCause}. - * - * @param message the detail message. The detail message is saved for - * later retrieval by the {@link #getMessage()} method. - */ - public IllegalParameterException(String message) { - super(message); - } -} diff --git a/src/main/java/com/wb/excel/api/exception/TemplateNotMatchException.java b/src/main/java/com/wb/excel/api/exception/TemplateNotMatchException.java deleted file mode 100644 index 969c4ee..0000000 --- a/src/main/java/com/wb/excel/api/exception/TemplateNotMatchException.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.wb.excel.api.exception; - -/** - * Created on 2014/10/12. - * - * @author - * @version 0.1.0 - */ -public class TemplateNotMatchException extends Exception { - /** - * Constructs a new exception with {@code null} as its detail message. - * The cause is not initialized, and may subsequently be initialized by a - * call to {@link #initCause}. - */ - public TemplateNotMatchException() { - } - - /** - * Constructs a new exception with the specified detail message. The - * cause is not initialized, and may subsequently be initialized by - * a call to {@link #initCause}. - * - * @param message the detail message. The detail message is saved for - * later retrieval by the {@link #getMessage()} method. - */ - public TemplateNotMatchException(String message) { - super(message); - } -} diff --git a/src/main/java/com/wb/excel/api/util/BaseVerifyUtil.java b/src/main/java/com/wb/excel/api/util/BaseVerifyUtil.java deleted file mode 100644 index 591eae1..0000000 --- a/src/main/java/com/wb/excel/api/util/BaseVerifyUtil.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.wb.excel.api.util; - - -import com.wb.excel.api.entity.DataVerifyResult; - -import java.util.regex.Pattern; - -/** - * *************************************************************** - *

- *

- * Copyright (c) 2014 –
- *  ColumnDescription:数据基础校验
- * ***************************************************************
- * 
- */ -public class BaseVerifyUtil { - private static String NOT_NULL = "不允许为空"; - private static String IS_MOBILE = "不是手机号"; - private static String IS_TEL = "不是电话号码"; - private static String IS_EMAIL = "不是邮箱地址"; - private static String MIN_LENGHT = "小于规定长度"; - private static String MAX_LENGHT = "超过规定长度"; - - private static Pattern mobilePattern = Pattern.compile("^[1][3,4,5,8,7][0-9]{9}$"); - - private static Pattern telPattern = Pattern.compile("^([0][1-9]{2,3}-)?[0-9]{5,10}$"); - - private static Pattern emailPattern = Pattern - .compile("^([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+\\.[a-zA-Z]{2,3}$"); - - - /** - * email校验 - * - * @param name - * @param val - * @return - */ - public static DataVerifyResult isEmail(String name, Object val) { - if (!emailPattern.matcher(String.valueOf(val)).matches()) { - return new DataVerifyResult(false, name + IS_EMAIL); - } - return new DataVerifyResult(true); - } - - /** - * 手机校验 - * - * @param name - * @param val - * @return - */ - public static DataVerifyResult isMobile(String name, Object val) { - if (!mobilePattern.matcher(String.valueOf(val)).matches()) { - return new DataVerifyResult(false, name + IS_MOBILE); - } - return new DataVerifyResult(true); - } - - /** - * 电话校验 - * - * @param name - * @param val - * @return - */ - public static DataVerifyResult isTel(String name, Object val) { - if (!telPattern.matcher(String.valueOf(val)).matches()) { - return new DataVerifyResult(false, name + IS_TEL); - } - return new DataVerifyResult(true); - } - - /** - * 最大长度校验 - * - * @param name - * @param val - * @return - */ - public static DataVerifyResult maxLength(String name, Object val, int maxLength) { - if (notNull(name, val).isSuccess() && String.valueOf(val).length() > maxLength) { - return new DataVerifyResult(false, name + MAX_LENGHT); - } - return new DataVerifyResult(true); - } - - /** - * 最小长度校验 - * - * @param name - * @param val - * @param minLength - * @return - */ - public static DataVerifyResult minLength(String name, Object val, int minLength) { - if (notNull(name, val).isSuccess() && String.valueOf(val).length() < minLength) { - return new DataVerifyResult(false, name + MIN_LENGHT); - } - return new DataVerifyResult(true); - } - - /** - * 非空校验 - * - * @param name - * @param val - * @return - */ - public static DataVerifyResult notNull(String name, Object val) { - if (val == null || val.toString().equals("")) { - return new DataVerifyResult(false, name + NOT_NULL); - } - return new DataVerifyResult(true); - } - - /** - * 正则表达式校验 - * - * @param name - * @param val - * @param regex - * @param regexTip - * @return - */ - public static DataVerifyResult regex(String name, Object val, String regex, - String regexTip) { - Pattern pattern = Pattern.compile(regex); - if (!pattern.matcher(String.valueOf(val)).matches()) { - return new DataVerifyResult(false, name + regexTip); - } - return new DataVerifyResult(true); - } -} diff --git a/src/main/java/com/wb/excel/api/util/DataTableUtil.java b/src/main/java/com/wb/excel/api/util/DataTableUtil.java deleted file mode 100644 index d55891f..0000000 --- a/src/main/java/com/wb/excel/api/util/DataTableUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.wb.excel.api.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * Created on 2014/10/12. - * - * @author - * @version 0.1.0 - */ -public class DataTableUtil { - - /** - * 测试用方法。从本地文件读取字节数据。 - * - * @param url 本地文件路径 - * @return 读取文件的byte数组 - * @throws java.io.IOException 读取文件中可能会抛出异常 - */ - public static byte[] readFile(String url) throws IOException { - File file = new File(url); - InputStream is = new FileInputStream(file); - Long length = file.length(); - if (length > Integer.MAX_VALUE) { - throw new IOException("文件过大,无法读取"); - } - - byte[] bytes = new byte[length.intValue()]; - int offset = 0; - int numRead; - while (offset < bytes.length - && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { - offset += numRead; - } - - //如果得到的字节长度和file实际的长度不一致就可能出错了 - if (offset < bytes.length) { - System.out.println("文件长度不一致"); - } - is.close(); - return bytes; - } -} diff --git a/src/main/java/com/wb/excel/api/util/StringUtil.java b/src/main/java/com/wb/excel/api/util/StringUtil.java deleted file mode 100644 index 674440c..0000000 --- a/src/main/java/com/wb/excel/api/util/StringUtil.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.wb.excel.api.util; - -import org.apache.poi.hssf.usermodel.HSSFDateUtil; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -public class StringUtil { - - public static int getByteLength(String str) { - int length = str.replaceAll("[^\\x00-\\xff]", "**").length(); - return length; - } - - public static String upperFirstWord(String str) { - String temp = str.substring(0, 1); - return temp.toUpperCase() + str.substring(1); - } - - /** - * TODO - * - * @param str - * @param reg - * @param index - * @return - */ - public static String split(String str, String reg, int index) { - if (reg.length() == 0) { - return str; - } - String[] strings = str.split(reg); - if (index < 0) { - index = 0; - } - if (index >= strings.length) { - index = strings.length - 1; - } - return strings[index]; - } - - public static String substring(String str, int start, int end) { - if (0 >= start || start >= str.length()) { - end = str.length() - 1; - } - if (0 >= end || end >= str.length()) { - end = str.length() - 1; - } - return str.substring(start, end); - } - - public static String transferDate(String value) { - Double d = TransferUtil.transferDouble(value); - Date date = null; - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - if (d == null) { - try { - date = sdf.parse(value); - } catch (ParseException e) { - e.printStackTrace(); - } - } else { - date = HSSFDateUtil.getJavaDate(d); - } - return sdf.format(date); - } - - public static String transferDatetime(String value) { - Double d = TransferUtil.transferDouble(value); - Date date = null; - - List sdfList = new ArrayList<>(); - sdfList.add("yyyy-MM-dd HH:mm:ss"); - sdfList.add("yyyy-MM-dd hh:mm:ss"); - sdfList.add("yyyy/MM/dd HH:mm:ss"); - sdfList.add("yyyy/MM/dd hh:mm:ss"); - - SimpleDateFormat stdFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - if (d == null) { - for (String sdfValue : sdfList) { - SimpleDateFormat sdf = new SimpleDateFormat(sdfValue); - try { - date = sdf.parse(value); - break; - } catch (ParseException ignored) { - } - } - } else { - date = HSSFDateUtil.getJavaDate(d); - } - return stdFormat.format(date); - } - -} diff --git a/src/main/java/com/wb/excel/api/util/StringUtils.java b/src/main/java/com/wb/excel/api/util/StringUtils.java deleted file mode 100644 index 2e91556..0000000 --- a/src/main/java/com/wb/excel/api/util/StringUtils.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.wb.excel.api.util; - -/** - * *************************************************************** - *

- *

- * Copyright (c) 2014 –
- *  ColumnDescription:
- * ***************************************************************
- * 
- */ -public class StringUtils { - private StringUtils() { - } - - /** - * 检查指定的字符串是否为空。 - * - * - * @param value 待检查的字符串 - * @return true/false - */ - public static boolean isEmpty(String value) { - int strLen; - if (value == null || (strLen = value.length()) == 0) { - return true; - } - for (int i = 0; i < strLen; i++) { - if ((Character.isWhitespace(value.charAt(i)) == false)) { - return false; - } - } - return true; - } - - public static boolean isNotEmpty(String value) { - int strLen; - if (value == null || (strLen = value.length()) == 0) { - return false; - } - for (int i = 0; i < strLen; i++) { - if ((Character.isWhitespace(value.charAt(i)) == false)) { - return true; - } - } - return false; - } - - /** - * 检查对象是否为数字型字符串,包含负数开头的。 - */ - public static boolean isNumeric(Object obj) { - if (obj == null) { - return false; - } - char[] chars = obj.toString().toCharArray(); - int length = chars.length; - if (length < 1) - return false; - - int i = 0; - if (length > 1 && chars[0] == '-') - i = 1; - - for (; i < length; i++) { - if (!Character.isDigit(chars[i])) { - return false; - } - } - return true; - } - - /** - * 检查指定的字符串列表是否不为空。 - */ - public static boolean areNotEmpty(String... values) { - boolean result = true; - if (values == null || values.length == 0) { - result = false; - } else { - for (String value : values) { - result &= !isEmpty(value); - } - } - return result; - } - - /** - * 把通用字符编码的字符串转化为汉字编码。 - */ - public static String unicodeToChinese(String unicode) { - StringBuilder out = new StringBuilder(); - if (!isEmpty(unicode)) { - for (int i = 0; i < unicode.length(); i++) { - out.append(unicode.charAt(i)); - } - } - return out.toString(); - } - - public static String toUnderlineStyle(String name) { - StringBuilder newName = new StringBuilder(); - for (int i = 0; i < name.length(); i++) { - char c = name.charAt(i); - if (Character.isUpperCase(c)) { - if (i > 0) { - newName.append("_"); - } - newName.append(Character.toLowerCase(c)); - } else { - newName.append(c); - } - } - return newName.toString(); - } -// -// public static String convertString(byte[] data, int offset, int length) { -// if(data == null) { -// return null; -// } else { -// try { -// return new String(data, offset, length, Constants.CHARSET_UTF8); -// } catch(Exception e) { -// throw new RuntimeException(e); -// } -// } -// } -// -// public static byte[] convertBytes(String data) { -// if(data == null) { -// return null; -// } else { -// try { -// return data.getBytes(Constants.CHARSET_UTF8); -// } catch(Exception e) { -// throw new RuntimeException(e); -// } -// } -// } -} diff --git a/src/main/java/com/wb/excel/api/util/TransferUtil.java b/src/main/java/com/wb/excel/api/util/TransferUtil.java deleted file mode 100644 index f5b0ec0..0000000 --- a/src/main/java/com/wb/excel/api/util/TransferUtil.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.wb.excel.api.util; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Created on 2014/9/27. - * - * @author - * @version 0.1.0 - */ -public class TransferUtil { - public static Date transferDate(String value) { - if (value == null) { - return null; - } - Date date = null; - try { - value = value.trim(); - if (value.matches("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - return sdf.parse(value); - } else if (value.matches("[0-9]{4}/[0-9]{1,2}/[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}")) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - return sdf.parse(value); - } else if (value.matches("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}")) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - date = sdf.parse(value); - } else if (value.matches("[0-9]{4}年[0-9]{1,2}月[0-9]{1,2}日 [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}")) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss"); - date = sdf.parse(value); - } - - } catch (ParseException e) { - e.printStackTrace(); - } - return date; - } - - public static Integer transferInteger(String value) { - try { - Double d = Double.parseDouble(value); - int i = d.intValue(); - if (d != i) { - return null; - } else { - return i; - } - } catch (Exception e) { - return null; - } - } - - public static Double transferDouble(String value) { - try { - return Double.parseDouble(value); - } catch (Exception e) { - return null; - } - } - - public static Long transferLong(String value) { - try { - Double d = Double.parseDouble(value); - long i = d.longValue(); - if (d != i) { - return null; - } else { - return i; - } - } catch (Exception e) { - return null; - } - } -} diff --git a/src/main/java/com/wb/excel/api/WCell.java b/src/main/java/xyz/wbsite/excel/WCell.java similarity index 95% rename from src/main/java/com/wb/excel/api/WCell.java rename to src/main/java/xyz/wbsite/excel/WCell.java index 9738363..b2eb1cc 100644 --- a/src/main/java/com/wb/excel/api/WCell.java +++ b/src/main/java/xyz/wbsite/excel/WCell.java @@ -1,4 +1,4 @@ -package com.wb.excel.api; +package xyz.wbsite.excel; import java.io.Serializable; diff --git a/src/main/java/com/wb/excel/api/WColumn.java b/src/main/java/xyz/wbsite/excel/WColumn.java similarity index 95% rename from src/main/java/com/wb/excel/api/WColumn.java rename to src/main/java/xyz/wbsite/excel/WColumn.java index bbb2b3e..b3758dc 100644 --- a/src/main/java/com/wb/excel/api/WColumn.java +++ b/src/main/java/xyz/wbsite/excel/WColumn.java @@ -1,8 +1,8 @@ -package com.wb.excel.api; +package xyz.wbsite.excel; -import com.wb.excel.api.converter.Converter; -import com.wb.excel.api.util.StringUtil; +import xyz.wbsite.excel.converter.Converter; +import xyz.wbsite.excel.util.StringUtil; import java.io.Serializable; import java.lang.reflect.Field; diff --git a/src/main/java/com/wb/excel/api/WRow.java b/src/main/java/xyz/wbsite/excel/WRow.java similarity index 95% rename from src/main/java/com/wb/excel/api/WRow.java rename to src/main/java/xyz/wbsite/excel/WRow.java index fce72d0..49dc064 100644 --- a/src/main/java/com/wb/excel/api/WRow.java +++ b/src/main/java/xyz/wbsite/excel/WRow.java @@ -1,4 +1,4 @@ -package com.wb.excel.api; +package xyz.wbsite.excel; import java.io.Serializable; import java.util.ArrayList; diff --git a/src/main/java/com/wb/excel/api/WSheet.java b/src/main/java/xyz/wbsite/excel/WSheet.java similarity index 92% rename from src/main/java/com/wb/excel/api/WSheet.java rename to src/main/java/xyz/wbsite/excel/WSheet.java index 5ddff8c..ce8c2f3 100644 --- a/src/main/java/com/wb/excel/api/WSheet.java +++ b/src/main/java/xyz/wbsite/excel/WSheet.java @@ -1,18 +1,19 @@ -package com.wb.excel.api; - -import com.wb.excel.api.annotation.*; -import com.wb.excel.api.converter.*; -import com.wb.excel.api.converter.Converter; -import com.wb.excel.api.exception.IllegalParameterException; -import com.wb.excel.api.exception.TemplateNotMatchException; -import com.wb.excel.api.style.*; -import com.wb.excel.api.util.ClassUtil; -import com.wb.excel.api.util.StringUtil; -import com.wb.excel.api.util.ValidationUtil; +package xyz.wbsite.excel; + +import xyz.wbsite.excel.style.DataCellStyle; +import xyz.wbsite.excel.style.ErrorCellStyle; +import xyz.wbsite.excel.style.HeadCellStyle; +import xyz.wbsite.excel.style.RedFont; +import xyz.wbsite.excel.util.ClassUtil; +import xyz.wbsite.excel.util.StringUtil; +import xyz.wbsite.excel.util.ValidationUtil; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.*; +import xyz.wbsite.excel.annotation.*; +import xyz.wbsite.excel.annotation.Converter; +import xyz.wbsite.excel.converter.*; import javax.validation.constraints.NotNull; import java.io.*; @@ -102,11 +103,11 @@ public class WSheet implements Serializable, Cloneable { } //获取列类型 - if (field.isAnnotationPresent(com.wb.excel.api.annotation.Converter.class)) { - com.wb.excel.api.annotation.Converter converter = field.getAnnotation(com.wb.excel.api.annotation.Converter.class); + if (field.isAnnotationPresent(Converter.class)) { + Converter converter = field.getAnnotation(Converter.class); Class target = converter.target(); try { - WColumn.setConverter((Converter) target.newInstance()); + WColumn.setConverter((xyz.wbsite.excel.converter.Converter) target.newInstance()); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { @@ -164,7 +165,7 @@ public class WSheet implements Serializable, Cloneable { */ public WSheet(List list) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { if (list == null || list.size() == 0) { - throw new IllegalParameterException("不允许传入空的列表"); + throw new RuntimeException("不允许传入空的列表"); } if (list.size() > 0) { List wColumns = initColumns(list.get(0).getClass()); @@ -204,12 +205,10 @@ public class WSheet implements Serializable, Cloneable { * * @param bytes Excel文件的字节数组 * @param clazz 类型 - * @throws IOException
1:输入流无法转为Excel文件 - 请检查输入的 bytes 是否正确;
- * 2:输入流关闭出错;
- * @throws TemplateNotMatchException
1:Excel文件的列数与对象类型不匹配 - 请检查Excel表与模板类是否一致;
- * 2:获取枚举类型出错 - 你在模板类中标注了一个变量的值为枚举类型,但程序寻找枚举类时出错;
+ * @throws IOException
1:输入流无法转为Excel文件 - 请检查输入的 bytes 是否正确;
+ * 2:输入流关闭出错;
*/ - public WSheet(byte[] bytes, Class clazz) throws IOException, TemplateNotMatchException { + public WSheet(byte[] bytes, Class clazz) throws IOException { Workbook workbook = null; InputStream is = null; boolean flag; @@ -233,7 +232,7 @@ public class WSheet implements Serializable, Cloneable { is.close(); } if (!flag) { - throw new TemplateNotMatchException("不支持的文件类型"); + throw new RuntimeException("不支持的文件类型"); } //第一张Sheet表 Sheet sheet = workbook.getSheetAt(0); @@ -253,7 +252,7 @@ public class WSheet implements Serializable, Cloneable { //检查列数量 List list = initColumns(clazz); if (list.size() != columnSum) { - throw new TemplateNotMatchException("与模板列数量不同。"); + throw new RuntimeException("与模板列数量不同。"); } else { for (int i = 0; i < list.size(); i++) { WColumn wColumn = list.get(i); @@ -263,7 +262,7 @@ public class WSheet implements Serializable, Cloneable { headValue = headValue.replace(" ", ""); if (!wColumn.getName().equals(headValue)) { - throw new TemplateNotMatchException("第" + (i + 1) + "项,不匹配的列名," + wColumn.getName() + "和" + headValue); + throw new RuntimeException("第" + (i + 1) + "项,不匹配的列名," + wColumn.getName() + "和" + headValue); } } } @@ -351,7 +350,7 @@ public class WSheet implements Serializable, Cloneable { String value = WCell.getValue(); Method method = clazz.getMethod("set" + att, field.getType()); //获取转换器 - Converter converter = column.getConverter(); + xyz.wbsite.excel.converter.Converter converter = column.getConverter(); method.invoke(object, converter.convert(value)); } break; diff --git a/src/main/java/com/wb/excel/api/annotation/ColumnDescription.java b/src/main/java/xyz/wbsite/excel/annotation/ColumnDescription.java similarity index 87% rename from src/main/java/com/wb/excel/api/annotation/ColumnDescription.java rename to src/main/java/xyz/wbsite/excel/annotation/ColumnDescription.java index 63dab9d..b367f7d 100644 --- a/src/main/java/com/wb/excel/api/annotation/ColumnDescription.java +++ b/src/main/java/xyz/wbsite/excel/annotation/ColumnDescription.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.annotation; +package xyz.wbsite.excel.annotation; import java.lang.annotation.*; diff --git a/src/main/java/com/wb/excel/api/annotation/ColumnName.java b/src/main/java/xyz/wbsite/excel/annotation/ColumnName.java similarity index 93% rename from src/main/java/com/wb/excel/api/annotation/ColumnName.java rename to src/main/java/xyz/wbsite/excel/annotation/ColumnName.java index d0d54aa..414b4e1 100644 --- a/src/main/java/com/wb/excel/api/annotation/ColumnName.java +++ b/src/main/java/xyz/wbsite/excel/annotation/ColumnName.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.annotation; +package xyz.wbsite.excel.annotation; import java.lang.annotation.*; diff --git a/src/main/java/com/wb/excel/api/annotation/Converter.java b/src/main/java/xyz/wbsite/excel/annotation/Converter.java similarity index 87% rename from src/main/java/com/wb/excel/api/annotation/Converter.java rename to src/main/java/xyz/wbsite/excel/annotation/Converter.java index 85b1816..4112574 100644 --- a/src/main/java/com/wb/excel/api/annotation/Converter.java +++ b/src/main/java/xyz/wbsite/excel/annotation/Converter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.annotation; +package xyz.wbsite.excel.annotation; import java.lang.annotation.*; diff --git a/src/main/java/com/wb/excel/api/annotation/Ignore.java b/src/main/java/xyz/wbsite/excel/annotation/Ignore.java similarity index 86% rename from src/main/java/com/wb/excel/api/annotation/Ignore.java rename to src/main/java/xyz/wbsite/excel/annotation/Ignore.java index afac939..b5919c0 100644 --- a/src/main/java/com/wb/excel/api/annotation/Ignore.java +++ b/src/main/java/xyz/wbsite/excel/annotation/Ignore.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.annotation; +package xyz.wbsite.excel.annotation; import java.lang.annotation.*; diff --git a/src/main/java/com/wb/excel/api/annotation/ParentFirst.java b/src/main/java/xyz/wbsite/excel/annotation/ParentFirst.java similarity index 87% rename from src/main/java/com/wb/excel/api/annotation/ParentFirst.java rename to src/main/java/xyz/wbsite/excel/annotation/ParentFirst.java index 8bcf2b8..9b5bacd 100644 --- a/src/main/java/com/wb/excel/api/annotation/ParentFirst.java +++ b/src/main/java/xyz/wbsite/excel/annotation/ParentFirst.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.annotation; +package xyz.wbsite.excel.annotation; import java.lang.annotation.*; diff --git a/src/main/java/com/wb/excel/api/annotation/SheetName.java b/src/main/java/xyz/wbsite/excel/annotation/SheetName.java similarity index 89% rename from src/main/java/com/wb/excel/api/annotation/SheetName.java rename to src/main/java/xyz/wbsite/excel/annotation/SheetName.java index 959fe6f..a362dad 100644 --- a/src/main/java/com/wb/excel/api/annotation/SheetName.java +++ b/src/main/java/xyz/wbsite/excel/annotation/SheetName.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.annotation; +package xyz.wbsite.excel.annotation; import java.lang.annotation.*; diff --git a/src/main/java/com/wb/excel/api/converter/BooleanConverter.java b/src/main/java/xyz/wbsite/excel/converter/BooleanConverter.java similarity index 91% rename from src/main/java/com/wb/excel/api/converter/BooleanConverter.java rename to src/main/java/xyz/wbsite/excel/converter/BooleanConverter.java index 10551ff..a4ff99a 100644 --- a/src/main/java/com/wb/excel/api/converter/BooleanConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/BooleanConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public class BooleanConverter implements Converter { diff --git a/src/main/java/com/wb/excel/api/converter/ByteConverter.java b/src/main/java/xyz/wbsite/excel/converter/ByteConverter.java similarity index 91% rename from src/main/java/com/wb/excel/api/converter/ByteConverter.java rename to src/main/java/xyz/wbsite/excel/converter/ByteConverter.java index 528dd56..f0c58f0 100644 --- a/src/main/java/com/wb/excel/api/converter/ByteConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/ByteConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public class ByteConverter implements Converter { diff --git a/src/main/java/com/wb/excel/api/converter/CharacterConverter.java b/src/main/java/xyz/wbsite/excel/converter/CharacterConverter.java similarity index 92% rename from src/main/java/com/wb/excel/api/converter/CharacterConverter.java rename to src/main/java/xyz/wbsite/excel/converter/CharacterConverter.java index 455c998..0eb3f5e 100644 --- a/src/main/java/com/wb/excel/api/converter/CharacterConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/CharacterConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public class CharacterConverter implements Converter { diff --git a/src/main/java/com/wb/excel/api/converter/Converter.java b/src/main/java/xyz/wbsite/excel/converter/Converter.java similarity index 71% rename from src/main/java/com/wb/excel/api/converter/Converter.java rename to src/main/java/xyz/wbsite/excel/converter/Converter.java index 6b8e33b..0aed253 100644 --- a/src/main/java/com/wb/excel/api/converter/Converter.java +++ b/src/main/java/xyz/wbsite/excel/converter/Converter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public interface Converter { diff --git a/src/main/java/com/wb/excel/api/converter/DateConverter.java b/src/main/java/xyz/wbsite/excel/converter/DateConverter.java similarity index 97% rename from src/main/java/com/wb/excel/api/converter/DateConverter.java rename to src/main/java/xyz/wbsite/excel/converter/DateConverter.java index ab4243c..e962db1 100644 --- a/src/main/java/com/wb/excel/api/converter/DateConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/DateConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; import java.text.ParseException; import java.text.SimpleDateFormat; diff --git a/src/main/java/com/wb/excel/api/converter/DoubleConverter.java b/src/main/java/xyz/wbsite/excel/converter/DoubleConverter.java similarity index 91% rename from src/main/java/com/wb/excel/api/converter/DoubleConverter.java rename to src/main/java/xyz/wbsite/excel/converter/DoubleConverter.java index 30b3771..d96faee 100644 --- a/src/main/java/com/wb/excel/api/converter/DoubleConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/DoubleConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public class DoubleConverter implements Converter { diff --git a/src/main/java/com/wb/excel/api/converter/FloatConverter.java b/src/main/java/xyz/wbsite/excel/converter/FloatConverter.java similarity index 93% rename from src/main/java/com/wb/excel/api/converter/FloatConverter.java rename to src/main/java/xyz/wbsite/excel/converter/FloatConverter.java index bf88a2e..e526518 100644 --- a/src/main/java/com/wb/excel/api/converter/FloatConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/FloatConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public class FloatConverter implements Converter { diff --git a/src/main/java/com/wb/excel/api/converter/IntegerConverter.java b/src/main/java/xyz/wbsite/excel/converter/IntegerConverter.java similarity index 91% rename from src/main/java/com/wb/excel/api/converter/IntegerConverter.java rename to src/main/java/xyz/wbsite/excel/converter/IntegerConverter.java index 4c98825..94c49e5 100644 --- a/src/main/java/com/wb/excel/api/converter/IntegerConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/IntegerConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public class IntegerConverter implements Converter { diff --git a/src/main/java/com/wb/excel/api/converter/LongConverter.java b/src/main/java/xyz/wbsite/excel/converter/LongConverter.java similarity index 95% rename from src/main/java/com/wb/excel/api/converter/LongConverter.java rename to src/main/java/xyz/wbsite/excel/converter/LongConverter.java index 7dc7ce9..92ea9b7 100644 --- a/src/main/java/com/wb/excel/api/converter/LongConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/LongConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; import java.util.regex.Matcher; diff --git a/src/main/java/com/wb/excel/api/converter/ShortConverter.java b/src/main/java/xyz/wbsite/excel/converter/ShortConverter.java similarity index 91% rename from src/main/java/com/wb/excel/api/converter/ShortConverter.java rename to src/main/java/xyz/wbsite/excel/converter/ShortConverter.java index 563e361..a47e741 100644 --- a/src/main/java/com/wb/excel/api/converter/ShortConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/ShortConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public class ShortConverter implements Converter { diff --git a/src/main/java/com/wb/excel/api/converter/StringConverter.java b/src/main/java/xyz/wbsite/excel/converter/StringConverter.java similarity index 89% rename from src/main/java/com/wb/excel/api/converter/StringConverter.java rename to src/main/java/xyz/wbsite/excel/converter/StringConverter.java index 7ecbaf0..b783f50 100644 --- a/src/main/java/com/wb/excel/api/converter/StringConverter.java +++ b/src/main/java/xyz/wbsite/excel/converter/StringConverter.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.converter; +package xyz.wbsite.excel.converter; public class StringConverter implements Converter { diff --git a/src/main/java/com/wb/excel/api/entity/DataVerifyResult.java b/src/main/java/xyz/wbsite/excel/entity/DataVerifyResult.java similarity index 96% rename from src/main/java/com/wb/excel/api/entity/DataVerifyResult.java rename to src/main/java/xyz/wbsite/excel/entity/DataVerifyResult.java index f19279a..cea0072 100644 --- a/src/main/java/com/wb/excel/api/entity/DataVerifyResult.java +++ b/src/main/java/xyz/wbsite/excel/entity/DataVerifyResult.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.entity; +package xyz.wbsite.excel.entity; import java.io.Serializable; diff --git a/src/main/java/com/wb/excel/api/entity/ExcelEntity.java b/src/main/java/xyz/wbsite/excel/entity/ExcelEntity.java similarity index 98% rename from src/main/java/com/wb/excel/api/entity/ExcelEntity.java rename to src/main/java/xyz/wbsite/excel/entity/ExcelEntity.java index f3f62a5..aaa1519 100644 --- a/src/main/java/com/wb/excel/api/entity/ExcelEntity.java +++ b/src/main/java/xyz/wbsite/excel/entity/ExcelEntity.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.entity; +package xyz.wbsite.excel.entity; import java.lang.reflect.Method; import java.util.List; diff --git a/src/main/java/com/wb/excel/api/style/BaseCellStyle.java b/src/main/java/xyz/wbsite/excel/style/BaseCellStyle.java similarity index 96% rename from src/main/java/com/wb/excel/api/style/BaseCellStyle.java rename to src/main/java/xyz/wbsite/excel/style/BaseCellStyle.java index 7529073..691159e 100644 --- a/src/main/java/com/wb/excel/api/style/BaseCellStyle.java +++ b/src/main/java/xyz/wbsite/excel/style/BaseCellStyle.java @@ -1,6 +1,5 @@ -package com.wb.excel.api.style; +package xyz.wbsite.excel.style; -import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.Workbook; diff --git a/src/main/java/com/wb/excel/api/style/BaseFont.java b/src/main/java/xyz/wbsite/excel/style/BaseFont.java similarity index 93% rename from src/main/java/com/wb/excel/api/style/BaseFont.java rename to src/main/java/xyz/wbsite/excel/style/BaseFont.java index 430c4dc..c7e98c7 100644 --- a/src/main/java/com/wb/excel/api/style/BaseFont.java +++ b/src/main/java/xyz/wbsite/excel/style/BaseFont.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.style; +package xyz.wbsite.excel.style; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Workbook; diff --git a/src/main/java/com/wb/excel/api/style/DataCellStyle.java b/src/main/java/xyz/wbsite/excel/style/DataCellStyle.java similarity index 96% rename from src/main/java/com/wb/excel/api/style/DataCellStyle.java rename to src/main/java/xyz/wbsite/excel/style/DataCellStyle.java index f0fcccf..f6833c7 100644 --- a/src/main/java/com/wb/excel/api/style/DataCellStyle.java +++ b/src/main/java/xyz/wbsite/excel/style/DataCellStyle.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.style; +package xyz.wbsite.excel.style; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.CellStyle; diff --git a/src/main/java/com/wb/excel/api/style/ErrorCellStyle.java b/src/main/java/xyz/wbsite/excel/style/ErrorCellStyle.java similarity index 94% rename from src/main/java/com/wb/excel/api/style/ErrorCellStyle.java rename to src/main/java/xyz/wbsite/excel/style/ErrorCellStyle.java index 04a8f2c..2a7bded 100644 --- a/src/main/java/com/wb/excel/api/style/ErrorCellStyle.java +++ b/src/main/java/xyz/wbsite/excel/style/ErrorCellStyle.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.style; +package xyz.wbsite.excel.style; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.CellStyle; diff --git a/src/main/java/com/wb/excel/api/style/HeadCellStyle.java b/src/main/java/xyz/wbsite/excel/style/HeadCellStyle.java similarity index 88% rename from src/main/java/com/wb/excel/api/style/HeadCellStyle.java rename to src/main/java/xyz/wbsite/excel/style/HeadCellStyle.java index 9d6ec1e..7bae036 100644 --- a/src/main/java/com/wb/excel/api/style/HeadCellStyle.java +++ b/src/main/java/xyz/wbsite/excel/style/HeadCellStyle.java @@ -1,8 +1,7 @@ -package com.wb.excel.api.style; +package xyz.wbsite.excel.style; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.Workbook; public class HeadCellStyle extends BaseCellStyle { diff --git a/src/main/java/com/wb/excel/api/style/NormalFont.java b/src/main/java/xyz/wbsite/excel/style/NormalFont.java similarity index 92% rename from src/main/java/com/wb/excel/api/style/NormalFont.java rename to src/main/java/xyz/wbsite/excel/style/NormalFont.java index f6cbb71..4ffbd85 100644 --- a/src/main/java/com/wb/excel/api/style/NormalFont.java +++ b/src/main/java/xyz/wbsite/excel/style/NormalFont.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.style; +package xyz.wbsite.excel.style; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.Workbook; diff --git a/src/main/java/com/wb/excel/api/style/RedFont.java b/src/main/java/xyz/wbsite/excel/style/RedFont.java similarity index 92% rename from src/main/java/com/wb/excel/api/style/RedFont.java rename to src/main/java/xyz/wbsite/excel/style/RedFont.java index 2d2fdc6..994c52a 100644 --- a/src/main/java/com/wb/excel/api/style/RedFont.java +++ b/src/main/java/xyz/wbsite/excel/style/RedFont.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.style; +package xyz.wbsite.excel.style; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.Workbook; diff --git a/src/main/java/com/wb/excel/api/util/ClassUtil.java b/src/main/java/xyz/wbsite/excel/util/ClassUtil.java similarity index 99% rename from src/main/java/com/wb/excel/api/util/ClassUtil.java rename to src/main/java/xyz/wbsite/excel/util/ClassUtil.java index 990fb71..3d3b23a 100644 --- a/src/main/java/com/wb/excel/api/util/ClassUtil.java +++ b/src/main/java/xyz/wbsite/excel/util/ClassUtil.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.util; +package xyz.wbsite.excel.util; import java.lang.reflect.Field; diff --git a/src/main/java/xyz/wbsite/excel/util/StringUtil.java b/src/main/java/xyz/wbsite/excel/util/StringUtil.java new file mode 100644 index 0000000..62b5759 --- /dev/null +++ b/src/main/java/xyz/wbsite/excel/util/StringUtil.java @@ -0,0 +1,87 @@ +package xyz.wbsite.excel.util; + +public class StringUtil { + + public static int getByteLength(String str) { + int length = str.replaceAll("[^\\x00-\\xff]", "**").length(); + return length; + } + + public static String upperFirstWord(String str) { + String temp = str.substring(0, 1); + return temp.toUpperCase() + str.substring(1); + } + + public static boolean isEmpty(String value) { + int strLen; + if (value == null || (strLen = value.length()) == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if ((Character.isWhitespace(value.charAt(i)) == false)) { + return false; + } + } + return true; + } + + + public static boolean isNotEmpty(String value) { + return !isEmpty(value); + } + + + /** + * 检查对象是否为数字型字符串,包含负数开头的。 + */ + public static boolean isNumeric(Object obj) { + if (obj == null) { + return false; + } + char[] chars = obj.toString().toCharArray(); + int length = chars.length; + if (length < 1) + return false; + + int i = 0; + if (length > 1 && chars[0] == '-') + i = 1; + + for (; i < length; i++) { + if (!Character.isDigit(chars[i])) { + return false; + } + } + return true; + } + + /** + * 把通用字符编码的字符串转化为汉字编码。 + */ + public static String unicodeToChinese(String unicode) { + StringBuilder out = new StringBuilder(); + if (!isEmpty(unicode)) { + for (int i = 0; i < unicode.length(); i++) { + out.append(unicode.charAt(i)); + } + } + return out.toString(); + } + + + public static String toUnderlineStyle(String name) { + StringBuilder newName = new StringBuilder(); + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + if (Character.isUpperCase(c)) { + if (i > 0) { + newName.append("_"); + } + newName.append(Character.toLowerCase(c)); + } else { + newName.append(c); + } + } + return newName.toString(); + } +} diff --git a/src/main/java/com/wb/excel/api/util/ValidationUtil.java b/src/main/java/xyz/wbsite/excel/util/ValidationUtil.java similarity index 97% rename from src/main/java/com/wb/excel/api/util/ValidationUtil.java rename to src/main/java/xyz/wbsite/excel/util/ValidationUtil.java index baf697f..543475a 100644 --- a/src/main/java/com/wb/excel/api/util/ValidationUtil.java +++ b/src/main/java/xyz/wbsite/excel/util/ValidationUtil.java @@ -1,4 +1,4 @@ -package com.wb.excel.api.util; +package xyz.wbsite.excel.util; import javax.validation.ConstraintViolation; import javax.validation.Validation; diff --git a/src/test/java/ExampleTest.java b/src/test/java/ExampleTest.java index 5d257bd..aaed47f 100644 --- a/src/test/java/ExampleTest.java +++ b/src/test/java/ExampleTest.java @@ -1,6 +1,4 @@ -import com.wb.excel.api.WSheet; -import com.wb.excel.api.exception.TemplateNotMatchException; - +import xyz.wbsite.excel.WSheet; import java.io.*; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -91,18 +89,16 @@ public class ExampleTest { } catch (FileNotFoundException e) { e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); - } catch (TemplateNotMatchException e) { + } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); } } diff --git a/src/test/java/User.java b/src/test/java/User.java index 3e4891d..2a9a6ee 100644 --- a/src/test/java/User.java +++ b/src/test/java/User.java @@ -1,6 +1,6 @@ -import com.wb.excel.api.annotation.ColumnDescription; -import com.wb.excel.api.annotation.ColumnName; -import com.wb.excel.api.annotation.SheetName; +import xyz.wbsite.excel.annotation.ColumnDescription; +import xyz.wbsite.excel.annotation.ColumnName; +import xyz.wbsite.excel.annotation.SheetName; import javax.validation.constraints.*; import java.util.Date;