From 7852593e5ed4a2dc09ce4c186c034783cf98ccea Mon Sep 17 00:00:00 2001 From: Jacket2013 <342115615@qq.com> Date: Mon, 19 Mar 2018 14:32:26 +0800 Subject: [PATCH] fixed bug: the value of config.name include space will cause export failure, eg: config.name = 'my test sheet' --- index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index ea2dbc4..eb80544 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,7 @@ var shareStrings, convertedShareStrings; function generateMultiSheets(configs, xlsx) { var i = 1; configs.forEach(function(config) { - config.name = config.name ? config.name : ('sheet'+i); + config.name = config.name ? encodeURIComponent(config.name) : ('sheet'+i); i++; var sheet = new Sheet(config, xlsx, shareStrings, convertedShareStrings); sheet.generate(); @@ -62,16 +62,16 @@ function generateRel(configs,xlsx) { workbook += relBack; xlsx.file('xl/_rels/workbook.xml.rels', workbook); xlsx.file('_rels/.rels', '' - + '' - + '' + + '' + + '' + ''); } function generateWorkbook(configs,xlsx) { var workbook = sheetsFront; - var i = 1; + var i = 1; configs.forEach( function(config) { - workbook += ''; + workbook += ''; i++; }); workbook += sheetsBack; @@ -99,8 +99,8 @@ exports.execute = function(config) { checkCRC32: false }); shareStrings = new SortedMap(); - convertedShareStrings = ""; - + convertedShareStrings = ""; + var configs = []; if (config instanceof Array) { configs = config; @@ -110,7 +110,7 @@ exports.execute = function(config) { generateMultiSheets(configs, xlsx); generateWorkbook(configs, xlsx); generateRel(configs,xlsx) ; - generateContentType(configs, xlsx); + generateContentType(configs, xlsx); generateSharedStringsFile(xlsx); var results = xlsx.generate({ base64: false,