Browse Source

fix:最下方和最后方合并单元格的问题

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

+ 5 - 5
services/excel/lucky_sheet.go

@@ -190,7 +190,7 @@ type LuckySheetDataValue struct {
 	TextBeak       int                       `json:"tb" description:"文本换行,	0 截断、1溢出、2 自动换行"`
 	Ps             LuckySheetDataCellComment `json:"ps" description:"批注"`
 	Function       string                    `json:"f" description:"公式"`
-	Mc             LuckySheetDataConfigMerge `json:"mc" description:"合并单元格信息"`
+	MergeCell      LuckySheetDataConfigMerge `json:"mc" description:"合并单元格信息"`
 }
 
 // LuckySheetDataCellType 单元格值格式:文本、时间等
@@ -362,7 +362,7 @@ func (item *LuckySheetData) GetTableDataByLuckySheetDataStr() (selfTableData Tab
 		for rowIndex := lenRow - 1; rowIndex >= 0; rowIndex-- {
 			isDelete := true
 			for _, v := range tableDataList[rowIndex] {
-				if v.Monitor != `` {
+				if v.Monitor != `` || v.MergeCell.Column != rowIndex {
 					isDelete = false
 					flag = true
 					break
@@ -419,12 +419,12 @@ func (item *LuckySheetData) GetTableDataByLuckySheetDataStr() (selfTableData Tab
 
 		// 移除后方空列
 		flag = false
-		//尾部
+		//后方
 		deleteTailColumnIndexList := make([]int, 0)
 		for columnIndex := lenColumn - 1; columnIndex >= 0; columnIndex-- {
 			isDelete := true
 			for _, v := range tableDataList {
-				if v[columnIndex].Monitor != `` {
+				if v[columnIndex].Monitor != `` || v[columnIndex].MergeCell.Column != columnIndex {
 					isDelete = false
 					flag = true
 					break
@@ -563,7 +563,7 @@ func HandleTableCell(oldTableData TableData) (newTableData TableData) {
 			tmpColumnDataList := newTableData.TableDataList[rowIndex]
 
 			newTableData.TableDataList[rowIndex] = append(tmpColumnDataList[:columnIndex], tmpColumnDataList[columnIndex+1:]...) // 删除开头N个元素
-			//fmt.Println("row:", rowIndex, "===column:", columnIndex)
+			fmt.Println("row:", rowIndex, "===column:", columnIndex)
 		}
 	}