chenjiahe
2023-10-08 8b3e27cbc244bc5e09ea1acd8a0a0546927e063d
新版excel优化
1个文件已修改
49 ■■■■ 已修改文件
src/main/java/com/hx/util/ExcelUtil.java 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/hx/util/ExcelUtil.java
@@ -976,33 +976,34 @@
                    cell = row.getCell(j);
                    if (cell == null) {
                        arrayString.add("");
                    }
                    if (cell.getCellType() == CellType.NUMERIC) {
                        isData = true;
                        format = cell.getCellStyle().getDataFormat();
                        if (format == 14 || format == 31 || format == 57 || format == 58) {
                            //日期(中文时间格式的)
                            d = cell.getDateCellValue();
                            formater = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                            arrayString.add(formater.format(d));
                        } else if (HSSFDateUtil.isCellDateFormatted(cell)) {
                            d = cell.getDateCellValue();
                            formater = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                            arrayString.add(formater.format(d));
                        } else {
                            if (CellType.STRING == cell.getCellType()) {
                                arrayString.add(cell.getStringCellValue());
                            } else if (CellType.FORMULA == cell.getCellType()) {
                                arrayString.add(cell.getCellFormula());
                    }else{
                        if (cell.getCellType() == CellType.NUMERIC) {
                            isData = true;
                            format = cell.getCellStyle().getDataFormat();
                            if (format == 14 || format == 31 || format == 57 || format == 58) {
                                //日期(中文时间格式的)
                                d = cell.getDateCellValue();
                                formater = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                                arrayString.add(formater.format(d));
                            } else if (HSSFDateUtil.isCellDateFormatted(cell)) {
                                d = cell.getDateCellValue();
                                formater = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                                arrayString.add(formater.format(d));
                            } else {
                                arrayString.add(cell.getStringCellValue().trim());
                                if (CellType.STRING == cell.getCellType()) {
                                    arrayString.add(cell.getStringCellValue());
                                } else if (CellType.FORMULA == cell.getCellType()) {
                                    arrayString.add(cell.getCellFormula());
                                } else {
                                    arrayString.add(cell.getStringCellValue().trim());
                                }
                            }
                        } else if (cell.getCellType() == CellType.BLANK) {
                            arrayString.add("");
                        } else { // 如果EXCEL表格中的数据类型为字符串型
                            isData = true;
                            arrayString.add(cell.getStringCellValue().trim());
                        }
                    } else if (cell.getCellType() == CellType.BLANK) {
                        arrayString.add("");
                    } else { // 如果EXCEL表格中的数据类型为字符串型
                        isData = true;
                        arrayString.add(cell.getStringCellValue().trim());
                    }
                }
                if (isData) {