java读取excel数据测试接口 @GetMapping(value = "/excel") public void excel() throws Exception { LOGGER.info("excel读取excel文件开始----"); InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("templates/excel.xlsx"); long t1 = System.currentTimeMillis(); XSSFWorkbook sheets = new XSSFWorkbook(in); XSSFSheet sheetAt = sheets.getSheetAt(0); for (Row row : sheetAt) { LOGGER.info("row.excelSyncGaoYang读取excel第" + row.getRowNum() + "行内容:{}", row); if(row.getRowNum() == 0) { continue; } int columnNum = row.getPhysicalNumberOfCells(); row.getCell(columnNum-1).setCellType(CellType.STRING); String phone= row.getCell(columnNum-2).getStringCellValue(); String createTime = row.getCell(columnNum-3).getStringCellValue(); Date date = new SimpleDateFormat("yyyy/MM/dd HH:mm").parse(createTime); String no= row.getCell(columnNum-4).getStringCellValue(); row.getCell(columnNum-1).setCellType(CellType.STRING); String dateStr = DateUtil.parseDate(new Date(), "yyyyMMddHHmmss"); long random = (long) ((Math.random() * 9 + 1) * 1000000); String transId = "SCBD" + dateStr + random; } long t2 = System.currentTimeMillis(); LOGGER.info("excel读取excel文件结束,用时:"+ (t2-t1)/1000 + "秒"); }
08-31
3206
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-19
11-04
9893
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-27