| | |
| | | package com.iailab.module.model.mpk.common.utils; |
| | | |
| | | |
| | | import com.iailab.module.model.common.utils.ASCIIUtil; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.*; |
| | |
| | | for (int k = 0; k < cells; k++) { |
| | | //获取每一个单元格的数据 |
| | | Cell cell = row.getCell(k, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); |
| | | doubles1[k] = cell.getNumericCellValue(); |
| | | CellType cellType = cell.getCellType(); |
| | | if (cellType.equals(CellType.NUMERIC)) { |
| | | doubles1[k] = cell.getNumericCellValue(); |
| | | } else if (cellType.equals(CellType.STRING)) { |
| | | // 校验数据格式 |
| | | if (k != 0) { |
| | | throw new RuntimeException(); |
| | | } |
| | | String stringCellValue = cell.getStringCellValue(); |
| | | doubles1 = ASCIIUtil.stringToAsciiArray(stringCellValue); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | doubles2[j] = doubles1; |
| | | } |
| | | datas.add(doubles2); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("解析Excel异常",e); |
| | | throw new RuntimeException("解析Excel异常", e); |
| | | } |
| | | |
| | | return datas; |