Skip to content

Commit 12f06c5

Browse files
committed
bugfix: 修复当只有一行数据时,因为单元格是自身问题导致的合并失败问题
1 parent 81dcd48 commit 12f06c5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

fastexcel-core/src/main/java/cn/idev/excel/write/merge/DynamicMergeStrategy.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,23 @@
1111
import java.util.Deque;
1212

1313
/**
14-
* @Description 指定列数据相同时进行单元格合并
15-
* @Author Zhuojianlong
14+
* @Description
15+
* @Author Mr.Zhou
1616
* @Date 2025/3/8
1717
*/
1818
public class DynamicMergeStrategy implements RowWriteHandler {
19+
20+
/**
21+
* You want to merge columns that are adjacent to the same cell data
22+
*/
1923
private final int columnIndex;
24+
/**
25+
* Extend column
26+
*/
2027
private final int columnExtend;
28+
/**
29+
* size of collection date
30+
*/
2131
private final int dataSize;
2232
private final Deque<MergeRow> rowStack = new ArrayDeque<>();
2333

@@ -31,6 +41,9 @@ public DynamicMergeStrategy(int columnIndex, int columnExtend,int dataSize) {
3141
if (columnIndex < 0) {
3242
throw new IllegalArgumentException("ColumnIndex must be greater than 0");
3343
}
44+
if(dataSize<=0){
45+
throw new IllegalArgumentException("dataSize must be greater than 0");
46+
}
3447
this.columnIndex = columnIndex;
3548
this.columnExtend = columnExtend;
3649
this.dataSize = dataSize;

0 commit comments

Comments
 (0)