修改解析文件数据
parent
9a9f4158fe
commit
3d08d302d9
@ -0,0 +1,45 @@
|
||||
package me.zhengjie.modules.uploadnew.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhengjie.modules.constant.DefaultConstant;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date : 2021/9/14
|
||||
*/
|
||||
@Slf4j
|
||||
public class ToolExcelUtils {
|
||||
|
||||
private ToolExcelUtils() {
|
||||
}
|
||||
|
||||
public static List<String> excelParseListByUrl(String fileUrl) {
|
||||
List<String> list = new ArrayList<>();
|
||||
ExcelReader reader = ExcelUtil.getReader(cn.hutool.core.io.FileUtil.file(fileUrl));
|
||||
if (CollectionUtils.isNotEmpty(reader.read())) {
|
||||
for (List<Object> objects : reader.read()) {
|
||||
String phone = objects.toString();
|
||||
if (phone.startsWith(StrUtil.BRACKET_START) && phone.endsWith(StrUtil.BRACKET_END)) {
|
||||
list.add(phone.substring(DefaultConstant.ONE_NUMBER, DefaultConstant.TWELVE_NUMBER));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static int countSizeByUrl(String fileUrl) {
|
||||
ExcelReader reader = ExcelUtil.getReader(cn.hutool.core.io.FileUtil.file(fileUrl));
|
||||
if (CollectionUtils.isNotEmpty(reader.read())) {
|
||||
return reader.read().size();
|
||||
}
|
||||
return DefaultConstant.ZERO_NUMBER;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue