潘志宝
2025-03-20 8688bfa3bba72f0e89520014a67454493b25e416
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/Readtxt.java
@@ -1,8 +1,8 @@
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.*;
@@ -132,14 +132,26 @@
                    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;