File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ class SharedStrings {
22 constructor ( ) {
33 this . _values = [ ] ;
44 this . _totalRefs = 0 ;
5- this . _hash = { } ;
5+ this . _hash = Object . create ( null ) ;
66 }
77
88 get count ( ) {
Original file line number Diff line number Diff line change 1+ const ExcelJS = verquire ( 'exceljs' ) ;
2+
3+ // this file to contain integration tests created from github issues
4+ const TEST_XLSX_FILE_NAME = './spec/out/wb.test.xlsx' ;
5+
6+ describe ( 'github issues' , ( ) => {
7+ it ( 'issue 1339 - Special cell value results invalid file' , async ( ) => {
8+ const wb = new ExcelJS . stream . xlsx . WorkbookWriter ( {
9+ filename : TEST_XLSX_FILE_NAME ,
10+ useStyles : true ,
11+ useSharedStrings : true ,
12+ } ) ;
13+ const ws = wb . addWorksheet ( 'Sheet1' ) ;
14+ const specialValues = [
15+ 'constructor' ,
16+ 'hasOwnProperty' ,
17+ 'isPrototypeOf' ,
18+ 'propertyIsEnumerable' ,
19+ 'toLocaleString' ,
20+ 'toString' ,
21+ 'valueOf' ,
22+ '__defineGetter__' ,
23+ '__defineSetter__' ,
24+ '__lookupGetter__' ,
25+ '__lookupSetter__' ,
26+ '__proto__' ,
27+ ] ;
28+ for ( let i = 0 , len = specialValues . length ; i < len ; i ++ ) {
29+ const value = specialValues [ i ] ;
30+ ws . addRow ( [ value ] ) ;
31+ ws . getCell ( `B${ i + 1 } ` ) . value = value ;
32+ }
33+ await wb . commit ( ) ;
34+ const wb2 = new ExcelJS . Workbook ( ) ;
35+ await wb2 . xlsx . readFile ( TEST_XLSX_FILE_NAME ) ;
36+ const ws2 = wb2 . getWorksheet ( 'Sheet1' ) ;
37+ for ( let i = 0 , len = specialValues . length ; i < len ; i ++ ) {
38+ const value = specialValues [ i ] ;
39+ expect ( ws2 . getCell ( `A${ i + 1 } ` ) . value ) . to . equal ( value ) ;
40+ expect ( ws2 . getCell ( `B${ i + 1 } ` ) . value ) . to . equal ( value ) ;
41+ }
42+ } ) ;
43+ } ) ;
You can’t perform that action at this time.
0 commit comments