"use strict"; // eslint-disable-line quotes
const _ = require('lodash');

const Worksheet = require('./worksheet');

class Workbook {
    constructor(x_wb) {
        if (x_wb) {
            _.extend(this, x_wb);
            this.Sheets = _.mapValues(this.Sheets, (sheet, name)=>new Worksheet(sheet, name, this));
        } else {
            this.SheetNames = [];
            this.Sheets = {};
        }
    }

    toJSON(opts) {
        return _.mapValues(this.Sheets, s=>s.toJSON(opts));
    }

    toArray(opts) {
        return _.map(this.Sheets, s=>s.toArray(opts));
    }
}
module.exports = Workbook;

@@ -398,24 +398,157 @@
      %7D%0A    %7D
+%0A    %0A    addSheet(ws) %7B%0A        this.SheetNames.push(ws.name);%0A        this.Sheets%5Bws.name%5D = ws;%0A        ws._workbook = this;%0A    %7D
 %0A%0A    toJSON

Add wb.addSheet