yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.qianwen.smartman.modules.mdc.strategy;
 
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import java.util.List;
import java.util.Map;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import com.qianwen.smartman.modules.mdc.dto.RowRangeDTO;
 
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/mdc/strategy/BizMergeStrategy.class */
public class BizMergeStrategy extends AbstractMergeStrategy {
    private final Map<String, List<RowRangeDTO>> strategyMap;
    private Sheet sheet;
 
    public BizMergeStrategy(Map<String, List<RowRangeDTO>> strategyMap) {
        this.strategyMap = strategyMap;
    }
 
    protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) {
        this.sheet = sheet;
        if (cell.getRowIndex() == 1 && cell.getColumnIndex() == 0) {
            for (Map.Entry<String, List<RowRangeDTO>> entry : this.strategyMap.entrySet()) {
                int columnIndex = Integer.parseInt(entry.getKey());
                entry.getValue().forEach(rowRange -> {
                    sheet.addMergedRegionUnsafe(new CellRangeAddress(rowRange.getStart().intValue(), rowRange.getEnd().intValue(), columnIndex, columnIndex));
                });
            }
        }
    }
}