File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -91,9 +91,13 @@ class Row {
91
91
cDst = this . getCell ( i ) ;
92
92
cDst . value = cSrc . value ;
93
93
cDst . style = cSrc . style ;
94
+ // eslint-disable-next-line no-underscore-dangle
95
+ cDst . _comment = cSrc . _comment ;
94
96
} else if ( cDst ) {
95
97
cDst . value = null ;
96
98
cDst . style = { } ;
99
+ // eslint-disable-next-line no-underscore-dangle
100
+ cDst . _comment = undefined ;
97
101
}
98
102
}
99
103
} else if ( nExpand > 0 ) {
@@ -104,6 +108,8 @@ class Row {
104
108
cDst = this . getCell ( i + nExpand ) ;
105
109
cDst . value = cSrc . value ;
106
110
cDst . style = cSrc . style ;
111
+ // eslint-disable-next-line no-underscore-dangle
112
+ cDst . _comment = cSrc . _comment ;
107
113
} else {
108
114
this . _cells [ i + nExpand - 1 ] = undefined ;
109
115
}
@@ -115,6 +121,8 @@ class Row {
115
121
cDst = this . getCell ( start + i ) ;
116
122
cDst . value = inserts [ i ] ;
117
123
cDst . style = { } ;
124
+ // eslint-disable-next-line no-underscore-dangle
125
+ cDst . _comment = undefined ;
118
126
}
119
127
}
120
128
Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments