Browse Source

fix:最后一列合并单元格时,就不再次移除合并的单元格,避免数组越界

Roc 2 years ago
parent
commit
50a9f652e3
1 changed files with 5 additions and 0 deletions
  1. 5 0
      services/excel/lucky_sheet.go

+ 5 - 0
services/excel/lucky_sheet.go

@@ -659,6 +659,11 @@ func HandleTableCell(oldTableData TableData) (newTableData TableData) {
 				continue
 			}
 			tmpColumnDataList := newTableData.TableDataList[rowIndex]
+
+			// 最后一列合并单元格时,就不再次移除合并的单元格,避免数组越界
+			if columnIndex >= len(tmpColumnDataList) {
+				continue
+			}
 			newTableData.TableDataList[rowIndex] = append(tmpColumnDataList[:columnIndex], tmpColumnDataList[columnIndex+1:]...) // 删除开头N个元素
 			//fmt.Println("row:", rowIndex, "===column:", columnIndex)
 		}