@@ -434,7 +434,7 @@ func (t *Table) getBorderLeft(hint renderHint) string {
434
434
} else if hint .isSeparatorRow {
435
435
if t .autoIndex && hint .isHeaderOrFooterSeparator () {
436
436
border = t .style .Box .Left
437
- } else if ! t .autoIndex && t .shouldMergeCellsVertically (0 , hint ) {
437
+ } else if ! t .autoIndex && t .shouldMergeCellsVerticallyAbove (0 , hint ) {
438
438
border = t .style .Box .Left
439
439
} else {
440
440
border = t .style .Box .LeftSeparator
@@ -454,7 +454,7 @@ func (t *Table) getBorderRight(hint renderHint) string {
454
454
} else if hint .isBorderBottom {
455
455
border = t .style .Box .BottomRight
456
456
} else if hint .isSeparatorRow {
457
- if t .shouldMergeCellsVertically (t .numColumns - 1 , hint ) {
457
+ if t .shouldMergeCellsVerticallyAbove (t .numColumns - 1 , hint ) {
458
458
border = t .style .Box .Right
459
459
} else {
460
460
border = t .style .Box .RightSeparator
@@ -525,12 +525,12 @@ func (t *Table) getColumnSeparator(row rowStr, colIdx int, hint renderHint) stri
525
525
}
526
526
527
527
func (t * Table ) getColumnSeparatorNonBorder (mergeCellsAbove bool , mergeCellsBelow bool , colIdx int , hint renderHint ) string {
528
- mergeNextCol := t .shouldMergeCellsVertically (colIdx , hint )
528
+ mergeNextCol := t .shouldMergeCellsVerticallyAbove (colIdx , hint )
529
529
if hint .isAutoIndexColumn {
530
530
return t .getColumnSeparatorNonBorderAutoIndex (mergeNextCol , hint )
531
531
}
532
532
533
- mergeCurrCol := t .shouldMergeCellsVertically (colIdx - 1 , hint )
533
+ mergeCurrCol := t .shouldMergeCellsVerticallyAbove (colIdx - 1 , hint )
534
534
return t .getColumnSeparatorNonBorderNonAutoIndex (mergeCellsAbove , mergeCellsBelow , mergeCurrCol , mergeNextCol )
535
535
}
536
536
@@ -839,7 +839,7 @@ func (t *Table) shouldMergeCellsHorizontallyBelow(row rowStr, colIdx int, hint r
839
839
return false
840
840
}
841
841
842
- func (t * Table ) shouldMergeCellsVertically (colIdx int , hint renderHint ) bool {
842
+ func (t * Table ) shouldMergeCellsVerticallyAbove (colIdx int , hint renderHint ) bool {
843
843
if ! t .firstRowOfPage && t .columnConfigMap [colIdx ].AutoMerge && colIdx < t .numColumns {
844
844
if hint .isSeparatorRow {
845
845
rowPrev := t .getRow (hint .rowNumber - 1 , hint )
@@ -858,6 +858,23 @@ func (t *Table) shouldMergeCellsVertically(colIdx int, hint renderHint) bool {
858
858
return false
859
859
}
860
860
861
+ func (t * Table ) shouldMergeCellsVerticallyBelow (colIdx int , hint renderHint ) int {
862
+ numRowsToMerge := 0
863
+ if t .columnConfigMap [colIdx ].AutoMerge && colIdx < t .numColumns {
864
+ numRowsToMerge = 1
865
+ rowCurr := t .getRow (hint .rowNumber - 1 , hint )
866
+ for rowIdx := hint .rowNumber ; rowIdx < len (t .rows ); rowIdx ++ {
867
+ rowNext := t .getRow (rowIdx , hint )
868
+ if colIdx < len (rowCurr ) && colIdx < len (rowNext ) && rowNext [colIdx ] == rowCurr [colIdx ] {
869
+ numRowsToMerge ++
870
+ } else {
871
+ break
872
+ }
873
+ }
874
+ }
875
+ return numRowsToMerge
876
+ }
877
+
861
878
func (t * Table ) shouldSeparateRows (rowIdx int , numRows int ) bool {
862
879
// not asked to separate rows and no manually added separator
863
880
if ! t .style .Options .SeparateRows && ! t .separators [rowIdx ] {
0 commit comments