UNPKG

@protobi/exceljs

Version:

Excel Workbook Manager - Temporary fork with pivot table enhancements and bug fixes pending upstream merge

79 lines (77 loc) 3.27 kB
"use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var colCache = require('../utils/col-cache'); var Anchor = require('./anchor'); var Image = /*#__PURE__*/function () { function Image(worksheet, model) { _classCallCheck(this, Image); this.worksheet = worksheet; this.model = model; } _createClass(Image, [{ key: "model", get: function get() { switch (this.type) { case 'background': return { type: this.type, imageId: this.imageId }; case 'image': return { type: this.type, imageId: this.imageId, hyperlinks: this.range.hyperlinks, range: { tl: this.range.tl.model, br: this.range.br && this.range.br.model, ext: this.range.ext, editAs: this.range.editAs } }; default: throw new Error('Invalid Image Type'); } }, set: function set(_ref) { var type = _ref.type, imageId = _ref.imageId, range = _ref.range, hyperlinks = _ref.hyperlinks; this.type = type; this.imageId = imageId; if (type === 'image') { if (typeof range === 'string') { var decoded = colCache.decode(range); this.range = { tl: new Anchor(this.worksheet, { col: decoded.left, row: decoded.top }, -1), br: new Anchor(this.worksheet, { col: decoded.right, row: decoded.bottom }, 0), editAs: 'oneCell' }; } else { this.range = { tl: new Anchor(this.worksheet, range.tl, 0), br: range.br && new Anchor(this.worksheet, range.br, 0), ext: range.ext, editAs: range.editAs, hyperlinks: hyperlinks || range.hyperlinks }; } } } }]); return Image; }(); module.exports = Image; //# sourceMappingURL=image.js.map