From 05185e13f2fe9c7047c86dbae0837d3a3dfa9136 Mon Sep 17 00:00:00 2001 From: MURAKAMI Masahiko Date: Tue, 14 Mar 2017 21:00:33 +0900 Subject: [PATCH] Fixed `vbaraw` parsing - fixes #594 h/t @fossamagna - fixes #348 h/t @aleramesh --- bits/85_parsezip.js | 2 +- test.js | 4 ++-- xlsx.flow.js | 2 +- xlsx.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bits/85_parsezip.js b/bits/85_parsezip.js index e9dc519..8b1aa01 100644 --- a/bits/85_parsezip.js +++ b/bits/85_parsezip.js @@ -135,7 +135,7 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ { out.files = zip.files; } if(opts.bookVBA) { - if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,dir.vba[0],true); + if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,dir.vba[0].replace(/^\//,''),true); else if(dir.defaults && dir.defaults.bin === 'application/vnd.ms-office.vbaProject') out.vbaraw = getzipdata(zip,'xl/vbaProject.bin',true); } return out; diff --git a/test.js b/test.js index 0f96d77..677b17b 100644 --- a/test.js +++ b/test.js @@ -434,9 +434,9 @@ describe('parse options', function() { }); it('bookVBA should generate vbaraw (XLSX/XLSB)', function() { var wb = X.readFile(paths.nfxlsx,{bookVBA:true}); - assert(typeof wb.vbaraw !== 'undefined'); + assert(wb.vbaraw); wb = X.readFile(paths.nfxlsb,{bookVBA:true}); - assert(typeof wb.vbaraw !== 'undefined'); + assert(wb.vbaraw); }); }); }); diff --git a/xlsx.flow.js b/xlsx.flow.js index b554074..5a1bd36 100644 --- a/xlsx.flow.js +++ b/xlsx.flow.js @@ -13280,7 +13280,7 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ { out.files = zip.files; } if(opts.bookVBA) { - if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,dir.vba[0],true); + if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,dir.vba[0].replace(/^\//,''),true); else if(dir.defaults && dir.defaults.bin === 'application/vnd.ms-office.vbaProject') out.vbaraw = getzipdata(zip,'xl/vbaProject.bin',true); } return out; diff --git a/xlsx.js b/xlsx.js index ae74ac6..b82edba 100644 --- a/xlsx.js +++ b/xlsx.js @@ -13223,7 +13223,7 @@ function parse_zip(zip, opts) { out.files = zip.files; } if(opts.bookVBA) { - if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,dir.vba[0],true); + if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,dir.vba[0].replace(/^\//,''),true); else if(dir.defaults && dir.defaults.bin === 'application/vnd.ms-office.vbaProject') out.vbaraw = getzipdata(zip,'xl/vbaProject.bin',true); } return out;