From 24a191579313236ef3a058968765a11e2c14d254 Mon Sep 17 00:00:00 2001 From: jueyue Date: Tue, 30 Jan 2018 17:31:39 +0800 Subject: [PATCH] =?UTF-8?q?groupName=E5=AF=BC=E8=87=B4=E7=9A=84=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../export/base/ExportCommonService.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java index 84a9b1a..87ea4b0 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java @@ -1,12 +1,12 @@ /** * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com) - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *

* http://www.apache.org/licenses/LICENSE-2.0 - * + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -321,13 +321,20 @@ public class ExportCommonService { Collections.sort(entry.getValue()); // 插入到excelParams当中 boolean isInsert = false; - for (int i = 0; i < excelParams.size() - 1; i++) { + String groupName = "START"; + for (int i = 0; i < excelParams.size(); i++) { // 跳过groupName 的元素,防止破会内部结构 - if (StringUtils.isEmpty(excelParams.get(i).getGroupName()) && excelParams.get(i).getOrderNum() <= entry.getValue().get(0).getOrderNum() - && excelParams.get(i + 1).getOrderNum() > entry.getValue().get(0).getOrderNum()) { - excelParams.addAll(i + 1, entry.getValue()); + if (excelParams.get(i).getOrderNum() > entry.getValue().get(0).getOrderNum() + && !groupName.equals(excelParams.get(i).getGroupName())) { + if (StringUtils.isNotEmpty(excelParams.get(i).getGroupName())) { + groupName = excelParams.get(i).getGroupName(); + } + excelParams.addAll(i, entry.getValue()); isInsert = true; break; + } else if (!groupName.equals(excelParams.get(i).getGroupName()) && + StringUtils.isNotEmpty(excelParams.get(i).getGroupName())) { + groupName = excelParams.get(i).getGroupName(); } } //如果都比他小就插入到最后