| | |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.apache.commons.lang3.RegExUtils; |
| | | import org.apache.commons.lang3.reflect.FieldUtils; |
| | |
| | | { |
| | | if (val instanceof String) |
| | | { |
| | | System.out.println("====++++++++"); |
| | | System.out.println(val); |
| | | if(((String) val).contains("/")) |
| | | val = ((String) val).replace("/","-"); |
| | | System.out.println(val); |
| | | val = DateUtils.parseDate(val); |
| | | } |
| | | else if (val instanceof Double) |
| | |
| | | for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) |
| | | { |
| | | Cell cell = row.getCell(i); |
| | | if (cell != null && cell.getCellType() != CellType.BLANK) |
| | | // System.out.println("11111111111111:/"+(cell != null)+"\n2222222222:/"+cell+"\n333333:/"+String.valueOf(cell).length()); |
| | | if (cell != null && cell.getCellType() != CellType.BLANK && !cell.toString().equals("")) |
| | | { |
| | | // System.out.println("444444+/"+(cell.getCellType())); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | } |
| | | return method; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 对excel表单默认第一个索引名转换成list(EasyExcel) |
| | | * |
| | | * @param is 输入流 |
| | | * @return 转换后集合 |
| | | */ |
| | | public List<T> importEasyExcel(InputStream is) throws Exception |
| | | { |
| | | return EasyExcel.read(is).head(clazz).sheet().doReadSync(); |
| | | } |
| | | |
| | | /** |
| | | * 对list数据源将其里面的数据导入到excel表单(EasyExcel) |
| | | * |
| | | * @param list 导出数据集合 |
| | | * @param sheetName 工作表的名称 |
| | | * @return 结果 |
| | | */ |
| | | public void exportEasyExcel(HttpServletResponse response, List<T> list, String sheetName) |
| | | { |
| | | try |
| | | { |
| | | EasyExcel.write(response.getOutputStream(), clazz).sheet(sheetName).doWrite(list); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | log.error("导出EasyExcel异常{}", e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |