如何部分更改合并单元格的边框?

How can I partially change the border of a merged cell?

所以给出这个代码:

var mergeCells = worksheet.Cells["A1:B5"];
mergeCells.Merge = true;
mergeCells.Style.Border.BorderAround(ExcelBorderStyle.Medium);

var notWorkingCell = worksheet.Cells["C1"];
notWorkingCell.Style.Border.Right.Style = ExcelBorderStyle.Medium;
notWorkingCell.Style.Border.Left.Style = ExcelBorderStyle.None; // <--This does not happen

我希望 notWorkingCell (C1) 周围的左边框会被删除。这没有发生:

如何部分更改合并单元格的边框?使用纯 Excel 是可能的。

看起来需要在 单元格地址上明确设置边框样式 合并单元格本身,而不是 ExcelRange:

var mergeCells = worksheet.Cells["A1:B5"];
mergeCells.Merge = true;
mergeCells.Style.Border.BorderAround(ExcelBorderStyle.Medium);

var notWorkingCell = worksheet.Cells["C1"];
notWorkingCell.Style.Border.Right.Style = ExcelBorderStyle.Medium;

var cellToLeft = notWorkingCell.Start;
worksheet.Cells[cellToLeft.Row, cellToLeft.Column - 1]
    .Style.Border.Right.Style = ExcelBorderStyle.None;