File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -249,11 +249,13 @@ class XLSX {
249249 if ( ! stream [ Symbol . asyncIterator ] && stream . pipe ) {
250250 stream = stream . pipe ( new PassThrough ( ) ) ;
251251 }
252- const chunks = [ ] ;
252+ let chunks = [ ] ;
253253 for await ( const chunk of stream ) {
254254 chunks . push ( chunk ) ;
255255 }
256- return this . load ( Buffer . concat ( chunks ) , options ) ;
256+ const buffer = Buffer . concat ( chunks ) ;
257+ chunks = null ;
258+ return this . load ( buffer , options ) ;
257259 }
258260
259261 async load ( data , options ) {
@@ -282,7 +284,8 @@ class XLSX {
282284 buffer = await officeCrypto . decrypt ( buffer , { password : options . password } ) ;
283285 }
284286
285- const zip = await JSZip . loadAsync ( buffer ) ;
287+ let zip = await JSZip . loadAsync ( buffer ) ;
288+ buffer = null ;
286289 for ( const entry of Object . values ( zip . files ) ) {
287290 /* eslint-disable no-await-in-loop */
288291 if ( ! entry . dir ) {
@@ -413,6 +416,7 @@ class XLSX {
413416 }
414417 }
415418 }
419+ zip = null ;
416420
417421 this . reconcile ( model , options ) ;
418422
Original file line number Diff line number Diff line change @@ -130,6 +130,24 @@ describe('WorkbookReader', () => {
130130 { maxRows : 20 }
131131 ) ;
132132 } ) ;
133+
134+ describe ( 'Big file support' , ( ) => {
135+ it ( 'should read large file correctly' , function ( done ) {
136+ this . timeout ( 20000 ) ;
137+ const workbook = new ExcelJS . Workbook ( ) ;
138+ workbook . xlsx
139+ . read (
140+ fs . createReadStream ( './spec/integration/data/extra-large.xlsx' )
141+ )
142+ . then ( result => {
143+ expect ( result . _worksheets [ 1 ] . _rows . length ) . to . equal ( 512781 ) ;
144+ expect (
145+ result . _worksheets [ 1 ] . _rows [ 500000 ] . _cells [ 4 ] . _value . value
146+ ) . to . equal ( 11 ) ;
147+ done ( ) ;
148+ } ) ;
149+ } ) ;
150+ } ) ;
133151 } ) ;
134152 } ) ;
135153
You can’t perform that action at this time.
0 commit comments