UNPKG

excel-builder

Version:

An easy way of building Excel files with javascript

50 lines (45 loc) 1.69 kB
"use strict"; var _ = require('lodash'); var AbsoluteAnchor = require('./AbsoluteAnchor'); var OneCellAnchor = require('./OneCellAnchor'); var TwoCellAnchor = require('./TwoCellAnchor'); /** * This is mostly a global spot where all of the relationship managers can get and set * path information from/to. * @module Excel/Drawing */ var Drawing = function () { this.id = _.uniqueId('Drawing'); }; _.extend(Drawing.prototype, { /** * * @param {String} type Can be 'absoluteAnchor', 'oneCellAnchor', or 'twoCellAnchor'. * @param {Object} config Shorthand - pass the created anchor coords that can normally be used to construct it. * @returns {Anchor} */ createAnchor: function (type, config) { config = config || {}; config.drawing = this; switch(type) { case 'absoluteAnchor': this.anchor = new AbsoluteAnchor(config); break; case 'oneCellAnchor': this.anchor = new OneCellAnchor(config); break; case 'twoCellAnchor': this.anchor = new TwoCellAnchor(config); break; } return this.anchor; } }); Object.defineProperties(Drawing, { AbsoluteAnchor: {get: function () { return require('./AbsoluteAnchor'); }}, Chart: {get: function () { return require('./Chart'); }}, OneCellAnchor: {get: function () { return require('./OneCellAnchor'); }}, Picture: {get: function () { return require('./Picture'); }}, TwoCellAnchor: {get: function () { return require('./TwoCellAnchor'); }} }); module.exports = Drawing;