From 756acbd7d971fbeebe224bdedfdd1a3e0a195dc2 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期一, 18 九月 2023 15:10:36 +0800 Subject: [PATCH] 新版excel优化 --- src/main/java/com/hx/util/ExcelUtil.java | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hx/util/ExcelUtil.java b/src/main/java/com/hx/util/ExcelUtil.java index 8418213..57bc636 100644 --- a/src/main/java/com/hx/util/ExcelUtil.java +++ b/src/main/java/com/hx/util/ExcelUtil.java @@ -1,6 +1,5 @@ package com.hx.util; -import com.alibaba.fastjson.JSON; import com.hx.exception.TipsException; import com.monitorjbl.xlsx.StreamingReader; import org.apache.poi.hssf.usermodel.*; @@ -956,15 +955,25 @@ Date d; DateFormat formater; Sheet sheet; + Cell cell; //閬嶅巻鎵�鏈夌殑sheet for(int i=0;i<book.getNumberOfSheets();i++) { sheet = book.getSheetAt(i); + //鍒楁暟 + Integer arrange = null; //閬嶅巻鎵�鏈夌殑琛� for (Row row : sheet) { + if(row == null){ + continue; + } isData = false; arrayString = new ArrayList<>(); + if(arrange == null){ + arrange = row.getPhysicalNumberOfCells(); + } //閬嶅巻鎵�鏈夌殑鍒� - for (Cell cell : row) { + for (int j = 0;j<arrange;j++) { + cell = row.getCell(j); if (cell == null) { arrayString.add(""); } else if (cell.getCellType() == CellType.NUMERIC) { -- Gitblit v1.8.0