@@ -29,7 +29,86 @@ describe('Workbook', () => {
2929testUtils . checkTestBook ( wb2 , 'xlsx' ) ;
3030} ) ;
3131} ) ;
32+ describe ( 'Xlsx Zip Compression' , ( ) => {
33+ it ( 'xlsx file with best compression' , ( ) => {
34+ const wb = testUtils . createTestBook ( new Excel . Workbook ( ) , 'xlsx' ) ;
3235
36+ return wb . xlsx
37+ . writeFile ( TEST_XLSX_FILE_NAME , {
38+ zip :{
39+ compression :'DEFLATE' ,
40+ compressionOptions :{
41+ level :9 ,
42+ } ,
43+ } ,
44+ } )
45+ . then ( ( ) => {
46+ const wb2 = new Excel . Workbook ( ) ;
47+ return wb2 . xlsx . readFile ( TEST_XLSX_FILE_NAME ) ;
48+ } )
49+ . then ( wb2 => {
50+ testUtils . checkTestBook ( wb2 , 'xlsx' ) ;
51+ } ) ;
52+ } ) ;
53+
54+ it ( 'xlsx file with default compression' , ( ) => {
55+ const wb = testUtils . createTestBook ( new Excel . Workbook ( ) , 'xlsx' ) ;
56+
57+ return wb . xlsx
58+ . writeFile ( TEST_XLSX_FILE_NAME , {
59+ zip :{
60+ compression :'DEFLATE' ,
61+ } ,
62+ } )
63+ . then ( ( ) => {
64+ const wb2 = new Excel . Workbook ( ) ;
65+ return wb2 . xlsx . readFile ( TEST_XLSX_FILE_NAME ) ;
66+ } )
67+ . then ( wb2 => {
68+ testUtils . checkTestBook ( wb2 , 'xlsx' ) ;
69+ } ) ;
70+ } ) ;
71+
72+
73+ it ( 'xlsx file with fast compression' , ( ) => {
74+ const wb = testUtils . createTestBook ( new Excel . Workbook ( ) , 'xlsx' ) ;
75+
76+ return wb . xlsx
77+ . writeFile ( TEST_XLSX_FILE_NAME , {
78+ zip :{
79+ compression :'DEFLATE' ,
80+ compressionOptions :{
81+ level :1 ,
82+ } ,
83+ } ,
84+ } )
85+ . then ( ( ) => {
86+ const wb2 = new Excel . Workbook ( ) ;
87+ return wb2 . xlsx . readFile ( TEST_XLSX_FILE_NAME ) ;
88+ } )
89+ . then ( wb2 => {
90+ testUtils . checkTestBook ( wb2 , 'xlsx' ) ;
91+ } ) ;
92+ } ) ;
93+
94+ it ( 'xlsx file with no compression' , ( ) => {
95+ const wb = testUtils . createTestBook ( new Excel . Workbook ( ) , 'xlsx' ) ;
96+
97+ return wb . xlsx
98+ . writeFile ( TEST_XLSX_FILE_NAME , {
99+ zip :{
100+ compression :'STORE' ,
101+ } ,
102+ } )
103+ . then ( ( ) => {
104+ const wb2 = new Excel . Workbook ( ) ;
105+ return wb2 . xlsx . readFile ( TEST_XLSX_FILE_NAME ) ;
106+ } )
107+ . then ( wb2 => {
108+ testUtils . checkTestBook ( wb2 , 'xlsx' ) ;
109+ } ) ;
110+ } ) ;
111+ } ) ;
33112it ( 'sheets with correct names' , ( ) => {
34113const wb = new Excel . Workbook ( ) ;
35114const ws1 = wb . addWorksheet ( 'Hello, World!' ) ;