-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64eda17
commit 2001856
Showing
10 changed files
with
185 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
core-parent/poi/src/main/java/icu/easyj/poi/excel/hook/ICellMerger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package icu.easyj.poi.excel.hook; | ||
|
||
import icu.easyj.poi.excel.model.ExcelCellMapping; | ||
|
||
public interface ICellMerger<T> { | ||
|
||
/** | ||
* 是否合并单元格 | ||
* | ||
* @param cellMapping 当前单元格 | ||
* @param previous 上一条数据 | ||
* @param current 当前数据 | ||
* @return 是否合并:true=合并 | false=不合并 | ||
*/ | ||
boolean needMerge(ExcelCellMapping cellMapping, T previous, T current); | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
core-parent/poi/src/main/java/icu/easyj/poi/excel/hook/NoneCellMerger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package icu.easyj.poi.excel.hook; | ||
|
||
import icu.easyj.poi.excel.model.ExcelCellMapping; | ||
|
||
public class NoneCellMerger implements ICellMerger<Object> { | ||
|
||
@Override | ||
public boolean needMerge(ExcelCellMapping cellMapping, Object previous, Object current) { | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
core-parent/poi/src/test/java/icu/easyj/poi/excel/util/hook/MyCellMerger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package icu.easyj.poi.excel.util.hook; | ||
|
||
import java.util.Objects; | ||
|
||
import icu.easyj.poi.excel.hook.ICellMerger; | ||
import icu.easyj.poi.excel.model.ExcelCellMapping; | ||
import icu.easyj.poi.excel.util.model.TestClass; | ||
|
||
public class MyCellMerger implements ICellMerger<TestClass> { | ||
|
||
@Override | ||
public boolean needMerge(ExcelCellMapping cellMapping, TestClass previous, TestClass current) { | ||
switch (cellMapping.getColumnFromFieldOrColumn()) { | ||
case "name": | ||
return Objects.equals(previous.getName(), current.getName()); | ||
case "age": | ||
return Objects.equals(previous.getName(), current.getName()) && | ||
Objects.equals(previous.getAge(), current.getAge()); | ||
case "bClass.age": | ||
return Objects.equals(previous.getName(), current.getName()) && | ||
Objects.equals( | ||
previous.getbClass() == null ? null : previous.getbClass().getAge(), | ||
current.getbClass() == null ? null : current.getbClass().getAge() | ||
); | ||
default: | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters