From eabd9ba14eae42726ee93ecae38112921d373213 Mon Sep 17 00:00:00 2001 From: Xiujun Ma Date: Thu, 4 Apr 2024 10:44:57 -0600 Subject: [PATCH 1/3] Fix: The bottom and right border styles do not correctly apply to cells when a merged cell is present at the end of the selection. --- src/core/data_proxy.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/core/data_proxy.js b/src/core/data_proxy.js index 1061a8626..d281bbe61 100644 --- a/src/core/data_proxy.js +++ b/src/core/data_proxy.js @@ -255,7 +255,8 @@ function setStyleBorders({ mode, style, color }) { ci += rows.getCellMerge(sri, ci)[1]; } if (mode === 'bottom') { - setStyleBorder.call(this, eri, ci, { bottom: [style, color] }); + const ri = getMergeCellRow(rows, ci, sri, eri); + setStyleBorder.call(this, ri, ci, { bottom: [style, color] }); ci += rows.getCellMerge(eri, ci)[1]; } } @@ -266,13 +267,40 @@ function setStyleBorders({ mode, style, color }) { ri += rows.getCellMerge(ri, sci)[0]; } if (mode === 'right') { - setStyleBorder.call(this, ri, eci, { right: [style, color] }); + const ci = getMergerCellColumn(rows, ri, sci, eci); + setStyleBorder.call(this, ri, ci, { right: [style, color] }); ri += rows.getCellMerge(ri, eci)[0]; } } } } +function getMergeCellRow(rows, ci, sri, eri) { + for (let ri = eri; ri >= sri; ri -= 1) { + const cell = rows.getCell(ri, ci); + if (cell && cell.merge) { + const [ rn ] = cell.merge; + if (ri + rn === eri) return ri; + return eri; + } + } + + return eri; +} + +function getMergerCellColumn(rows, ri, sci, eci) { + for (let ci = eci; ci >= sci; ci -= 1) { + const cell = rows.getCell(ri, ci); + if (cell && cell.merge) { + const [_, cn] = cell.merge; + if (ci + cn === eci) return ci; + return eci; + } + } + + return eci; +} + function getCellRowByY(y, scrollOffsety) { const { rows } = this; const fsh = this.freezeTotalHeight(); From cc4273d6f611661c5b3393ac6bda38b3d8de4e65 Mon Sep 17 00:00:00 2001 From: Xiujun Ma Date: Thu, 4 Apr 2024 10:53:09 -0600 Subject: [PATCH 2/3] Fix: The bottom and right border styles do not correctly apply to cells when a merged cell is present at the end of the selection. --- src/core/data_proxy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/data_proxy.js b/src/core/data_proxy.js index d281bbe61..438886854 100644 --- a/src/core/data_proxy.js +++ b/src/core/data_proxy.js @@ -257,7 +257,7 @@ function setStyleBorders({ mode, style, color }) { if (mode === 'bottom') { const ri = getMergeCellRow(rows, ci, sri, eri); setStyleBorder.call(this, ri, ci, { bottom: [style, color] }); - ci += rows.getCellMerge(eri, ci)[1]; + ci += rows.getCellMerge(ri, ci)[1]; } } } else if (mode === 'left' || mode === 'right') { @@ -269,7 +269,7 @@ function setStyleBorders({ mode, style, color }) { if (mode === 'right') { const ci = getMergerCellColumn(rows, ri, sci, eci); setStyleBorder.call(this, ri, ci, { right: [style, color] }); - ri += rows.getCellMerge(ri, eci)[0]; + ri += rows.getCellMerge(ri, ci)[0]; } } } From f9221800add6b3f39a4c6a4108ca93a85f8636f1 Mon Sep 17 00:00:00 2001 From: Xiujun Ma Date: Thu, 4 Apr 2024 10:57:47 -0600 Subject: [PATCH 3/3] Fix: The bottom and right border styles do not correctly apply to cells when a merged cell is present at the end of the selection. --- src/core/data_proxy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/data_proxy.js b/src/core/data_proxy.js index 438886854..f2770a282 100644 --- a/src/core/data_proxy.js +++ b/src/core/data_proxy.js @@ -267,7 +267,7 @@ function setStyleBorders({ mode, style, color }) { ri += rows.getCellMerge(ri, sci)[0]; } if (mode === 'right') { - const ci = getMergerCellColumn(rows, ri, sci, eci); + const ci = getMergeCellColumn(rows, ri, sci, eci); setStyleBorder.call(this, ri, ci, { right: [style, color] }); ri += rows.getCellMerge(ri, ci)[0]; } @@ -288,7 +288,7 @@ function getMergeCellRow(rows, ci, sri, eri) { return eri; } -function getMergerCellColumn(rows, ri, sci, eci) { +function getMergeCellColumn(rows, ri, sci, eci) { for (let ci = eci; ci >= sci; ci -= 1) { const cell = rows.getCell(ri, ci); if (cell && cell.merge) {