Skip to content

Commit

Permalink
Merge pull request #231 from pookong/remove_empty_worksheet0
Browse files Browse the repository at this point in the history
remove empty worksheet[0] from _worksheets
  • Loading branch information
guyonroche authored Dec 2, 2016
2 parents aaca364 + 788bb40 commit d20efed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/doc/workbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Workbook.prototype = {

get worksheets() {
// return a clone of _worksheets
return this._worksheets.filter(function(worksheet) { return worksheet; });
return this._worksheets.filter(Boolean);
},

eachSheet: function(iteratee) {
Expand All @@ -140,7 +140,7 @@ Workbook.prototype = {
lastPrinted: this.lastPrinted,
created: this.created,
modified: this.modified,
worksheets: this._worksheets.map(function(worksheet) { return worksheet.model; }),
worksheets: this._worksheets.filter(Boolean).map(function(worksheet) { return worksheet.model; }),
definedNames: this._definedNames.model,
views: this.views,
company: this.company,
Expand Down Expand Up @@ -189,4 +189,4 @@ Workbook.prototype = {
this._definedNames.model = value.definedNames;
this.views = value.views;
}
};
};
6 changes: 3 additions & 3 deletions lib/stream/xlsx/workbook-writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ WorkbookWriter.prototype = {
var self = this;
return new Bluebird(function(resolve) {
var model = {
worksheets: self._worksheets
worksheets: self._worksheets.filter(Boolean)
};
var xform = new ContentTypesXform();
var xml = xform.toXml(model);
Expand All @@ -240,7 +240,7 @@ WorkbookWriter.prototype = {
var self = this;
return new Bluebird(function(resolve) {
var model = {
worksheets: self._worksheets
worksheets: self._worksheets.filter(Boolean)
};
var xform = new AppXform();
var xml = xform.toXml(model);
Expand Down Expand Up @@ -300,7 +300,7 @@ WorkbookWriter.prototype = {
addWorkbook: function() {
var zip = this.zip;
var model = {
worksheets: this._worksheets,
worksheets: this._worksheets.filter(Boolean),
definedNames: this._definedNames.model,
views: this.views
};
Expand Down

0 comments on commit d20efed

Please sign in to comment.