parent
6314510243
commit
a2d0f6184c
@ -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
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<String> 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);
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api;
|
||||
package xyz.wbsite.excel;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
@ -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;
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api;
|
||||
package xyz.wbsite.excel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.annotation;
|
||||
package xyz.wbsite.excel.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.annotation;
|
||||
package xyz.wbsite.excel.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.annotation;
|
||||
package xyz.wbsite.excel.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.annotation;
|
||||
package xyz.wbsite.excel.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.annotation;
|
||||
package xyz.wbsite.excel.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.annotation;
|
||||
package xyz.wbsite.excel.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
public class BooleanConverter implements Converter<Boolean> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
public class ByteConverter implements Converter<Byte> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
public class CharacterConverter implements Converter<Character> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
|
||||
public interface Converter<T> {
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
public class DoubleConverter implements Converter<Double> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
public class FloatConverter implements Converter<Float> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
public class IntegerConverter implements Converter<Integer> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
|
||||
import java.util.regex.Matcher;
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
public class ShortConverter implements Converter<Short> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.converter;
|
||||
package xyz.wbsite.excel.converter;
|
||||
|
||||
public class StringConverter implements Converter<String> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.entity;
|
||||
package xyz.wbsite.excel.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.entity;
|
||||
package xyz.wbsite.excel.entity;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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 {
|
@ -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;
|
@ -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;
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.util;
|
||||
package xyz.wbsite.excel.util;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
@ -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();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.wb.excel.api.util;
|
||||
package xyz.wbsite.excel.util;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validation;
|
Loading…
Reference in new issue