Skip to content

Commit e2aab24

Browse files
authored
Merge pull request #1334 from sdg9670/splice-comment-issue
Fix the error that comment does not delete at spliceColumn
2 parents ec22202 + 64468ee commit e2aab24

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

lib/doc/row.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ class Row {
9191
cDst = this.getCell(i);
9292
cDst.value = cSrc.value;
9393
cDst.style = cSrc.style;
94+
// eslint-disable-next-line no-underscore-dangle
95+
cDst._comment = cSrc._comment;
9496
} else if (cDst) {
9597
cDst.value = null;
9698
cDst.style = {};
99+
// eslint-disable-next-line no-underscore-dangle
100+
cDst._comment = undefined;
97101
}
98102
}
99103
} else if (nExpand > 0) {
@@ -104,6 +108,8 @@ class Row {
104108
cDst = this.getCell(i + nExpand);
105109
cDst.value = cSrc.value;
106110
cDst.style = cSrc.style;
111+
// eslint-disable-next-line no-underscore-dangle
112+
cDst._comment = cSrc._comment;
107113
} else {
108114
this._cells[i + nExpand - 1] = undefined;
109115
}
@@ -115,6 +121,8 @@ class Row {
115121
cDst = this.getCell(start + i);
116122
cDst.value = inserts[i];
117123
cDst.style = {};
124+
// eslint-disable-next-line no-underscore-dangle
125+
cDst._comment = undefined;
118126
}
119127
}
120128

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const ExcelJS = verquire('exceljs');
2+
3+
const TEST_XLSX_FILE_NAME = './spec/out/wb.test.xlsx';
4+
5+
describe('github issues', () => {
6+
it('pull request 1334 - Fix the error that comment does not delete at spliceColumn', async () => {
7+
(async () => {
8+
const wb = new ExcelJS.Workbook();
9+
const ws = wb.addWorksheet('testSheet');
10+
11+
ws.addRow([
12+
'test1',
13+
'test2',
14+
'test3',
15+
'test4',
16+
'test5',
17+
'test6',
18+
'test7',
19+
'test8',
20+
]);
21+
22+
const row = ws.getRow(1);
23+
row.getCell(1).note = 'test1';
24+
row.getCell(2).note = 'test2';
25+
row.getCell(3).note = 'test3';
26+
row.getCell(4).note = 'test4';
27+
28+
ws.spliceColumns(2, 1);
29+
30+
expect(row.getCell(1).note).to.equal('test1');
31+
expect(row.getCell(2).note).to.equal('test3');
32+
expect(row.getCell(3).note).to.equal('test4');
33+
expect(row.getCell(4).note).to.equal(undefined);
34+
35+
await wb.xlsx.writeFile(TEST_XLSX_FILE_NAME);
36+
})();
37+
});
38+
});

0 commit comments

Comments
 (0)