//设置合并数据
function setMerge(luckyMerge, worksheet) {
const mergearr = Object.values(luckyMerge);
mergearr.forEach(function (elem) {
const startCell = `${createCol(elem.c)}${elem.r + 1}`
const endCell = `${createCol(elem.c + elem.cs - 1)}${elem.r + elem.rs}`
const end_border = worksheet.getCell(`${endCell}`).border
const start_border = worksheet.getCell(`${startCell}`).border
const border = {}
if (start_border) {
border.top = start_border.top
border.left = start_border.left
}
if (end_border) {
border.bottom = end_border.bottom
border.right = end_border.right
}
worksheet.mergeCells(`${startCell}:${endCell}`);
worksheet.getCell(`${startCell}:${endCell}`).border = border
});
}
需要对合并后的单元格再做边框处理,分别取开始单元格的上边框和左边框,结束单元格的右边框和下边框