| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912 |
- "use strict";
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
- function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
- function _awaitAsyncGenerator(value) { return new _AwaitValue(value); }
- function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; }
- function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen.return !== "function") { this.return = undefined; } }
- if (typeof Symbol === "function" && Symbol.asyncIterator) { _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; }; }
- _AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
- _AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };
- _AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); };
- function _AwaitValue(value) { this.wrapped = value; }
- function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); }
- var _require = require('events'),
- EventEmitter = _require.EventEmitter;
- var parseSax = require('../../utils/parse-sax');
- var _ = require('../../utils/under-dash');
- var utils = require('../../utils/utils');
- var colCache = require('../../utils/col-cache');
- var Dimensions = require('../../doc/range');
- var Row = require('../../doc/row');
- var Column = require('../../doc/column');
- var WorksheetReader = /*#__PURE__*/function (_EventEmitter) {
- _inherits(WorksheetReader, _EventEmitter);
- var _super = _createSuper(WorksheetReader);
- function WorksheetReader(_ref) {
- var _this3;
- var workbook = _ref.workbook,
- id = _ref.id,
- iterator = _ref.iterator,
- options = _ref.options;
- _classCallCheck(this, WorksheetReader);
- _this3 = _super.call(this);
- _this3.workbook = workbook;
- _this3.id = id;
- _this3.iterator = iterator;
- _this3.options = options || {}; // and a name
- _this3.name = "Sheet".concat(_this3.id); // column definitions
- _this3._columns = null;
- _this3._keys = {}; // keep a record of dimensions
- _this3._dimensions = new Dimensions();
- return _this3;
- } // destroy - not a valid operation for a streaming writer
- // even though some streamers might be able to, it's a bad idea.
- _createClass(WorksheetReader, [{
- key: "destroy",
- value: function destroy() {
- throw new Error('Invalid Operation: destroy');
- } // return the current dimensions of the writer
- }, {
- key: "getColumn",
- // get a single column by col number. If it doesn't exist, it and any gaps before it
- // are created.
- value: function getColumn(c) {
- if (typeof c === 'string') {
- // if it matches a key'd column, return that
- var col = this._keys[c];
- if (col) {
- return col;
- } // otherise, assume letter
- c = colCache.l2n(c);
- }
- if (!this._columns) {
- this._columns = [];
- }
- if (c > this._columns.length) {
- var n = this._columns.length + 1;
- while (n <= c) {
- this._columns.push(new Column(this, n++));
- }
- }
- return this._columns[c - 1];
- }
- }, {
- key: "getColumnKey",
- value: function getColumnKey(key) {
- return this._keys[key];
- }
- }, {
- key: "setColumnKey",
- value: function setColumnKey(key, value) {
- this._keys[key] = value;
- }
- }, {
- key: "deleteColumnKey",
- value: function deleteColumnKey(key) {
- delete this._keys[key];
- }
- }, {
- key: "eachColumnKey",
- value: function eachColumnKey(f) {
- _.each(this._keys, f);
- }
- }, {
- key: "read",
- value: function () {
- var _read = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
- var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, events, _iterator4, _step4, _step4$value, eventType, value;
- return regeneratorRuntime.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.prev = 0;
- _iteratorNormalCompletion = true;
- _didIteratorError = false;
- _context.prev = 3;
- _iterator = _asyncIterator(this.parse());
- case 5:
- _context.next = 7;
- return _iterator.next();
- case 7:
- _step = _context.sent;
- _iteratorNormalCompletion = _step.done;
- _context.next = 11;
- return _step.value;
- case 11:
- _value = _context.sent;
- if (_iteratorNormalCompletion) {
- _context.next = 19;
- break;
- }
- events = _value;
- _iterator4 = _createForOfIteratorHelper(events);
- try {
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
- _step4$value = _step4.value, eventType = _step4$value.eventType, value = _step4$value.value;
- this.emit(eventType, value);
- }
- } catch (err) {
- _iterator4.e(err);
- } finally {
- _iterator4.f();
- }
- case 16:
- _iteratorNormalCompletion = true;
- _context.next = 5;
- break;
- case 19:
- _context.next = 25;
- break;
- case 21:
- _context.prev = 21;
- _context.t0 = _context["catch"](3);
- _didIteratorError = true;
- _iteratorError = _context.t0;
- case 25:
- _context.prev = 25;
- _context.prev = 26;
- if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
- _context.next = 30;
- break;
- }
- _context.next = 30;
- return _iterator.return();
- case 30:
- _context.prev = 30;
- if (!_didIteratorError) {
- _context.next = 33;
- break;
- }
- throw _iteratorError;
- case 33:
- return _context.finish(30);
- case 34:
- return _context.finish(25);
- case 35:
- this.emit('finished');
- _context.next = 41;
- break;
- case 38:
- _context.prev = 38;
- _context.t1 = _context["catch"](0);
- this.emit('error', _context.t1);
- case 41:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this, [[0, 38], [3, 21, 25, 35], [26,, 30, 34]]);
- }));
- function read() {
- return _read.apply(this, arguments);
- }
- return read;
- }()
- }, {
- key: Symbol.asyncIterator,
- value: function value() {
- var _this = this;
- return _wrapAsyncGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
- var _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, events, _iterator5, _step5, _step5$value, eventType, value;
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _iteratorNormalCompletion2 = true;
- _didIteratorError2 = false;
- _context2.prev = 2;
- _iterator2 = _asyncIterator(_this.parse());
- case 4:
- _context2.next = 6;
- return _awaitAsyncGenerator(_iterator2.next());
- case 6:
- _step2 = _context2.sent;
- _iteratorNormalCompletion2 = _step2.done;
- _context2.next = 10;
- return _awaitAsyncGenerator(_step2.value);
- case 10:
- _value2 = _context2.sent;
- if (_iteratorNormalCompletion2) {
- _context2.next = 34;
- break;
- }
- events = _value2;
- _iterator5 = _createForOfIteratorHelper(events);
- _context2.prev = 14;
- _iterator5.s();
- case 16:
- if ((_step5 = _iterator5.n()).done) {
- _context2.next = 23;
- break;
- }
- _step5$value = _step5.value, eventType = _step5$value.eventType, value = _step5$value.value;
- if (!(eventType === 'row')) {
- _context2.next = 21;
- break;
- }
- _context2.next = 21;
- return value;
- case 21:
- _context2.next = 16;
- break;
- case 23:
- _context2.next = 28;
- break;
- case 25:
- _context2.prev = 25;
- _context2.t0 = _context2["catch"](14);
- _iterator5.e(_context2.t0);
- case 28:
- _context2.prev = 28;
- _iterator5.f();
- return _context2.finish(28);
- case 31:
- _iteratorNormalCompletion2 = true;
- _context2.next = 4;
- break;
- case 34:
- _context2.next = 40;
- break;
- case 36:
- _context2.prev = 36;
- _context2.t1 = _context2["catch"](2);
- _didIteratorError2 = true;
- _iteratorError2 = _context2.t1;
- case 40:
- _context2.prev = 40;
- _context2.prev = 41;
- if (!(!_iteratorNormalCompletion2 && _iterator2.return != null)) {
- _context2.next = 45;
- break;
- }
- _context2.next = 45;
- return _awaitAsyncGenerator(_iterator2.return());
- case 45:
- _context2.prev = 45;
- if (!_didIteratorError2) {
- _context2.next = 48;
- break;
- }
- throw _iteratorError2;
- case 48:
- return _context2.finish(45);
- case 49:
- return _context2.finish(40);
- case 50:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, null, [[2, 36, 40, 50], [14, 25, 28, 31], [41,, 45, 49]]);
- }))();
- }
- }, {
- key: "parse",
- value: function parse() {
- var _this2 = this;
- return _wrapAsyncGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
- var iterator, options, emitSheet, emitHyperlinks, hyperlinks, _this2$workbook, sharedStrings, styles, properties, inCols, inRows, inHyperlinks, cols, row, c, current, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _value3, events, worksheetEvents, _iterator6, _step6, _step6$value, eventType, value, node, r, styleId, style, hyperlink, _node, address, cell, _style, cellValue, index, _hyperlink;
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- iterator = _this2.iterator, options = _this2.options;
- emitSheet = false;
- emitHyperlinks = false;
- hyperlinks = null;
- _context3.t0 = options.worksheets;
- _context3.next = _context3.t0 === 'emit' ? 7 : _context3.t0 === 'prep' ? 9 : 10;
- break;
- case 7:
- emitSheet = true;
- return _context3.abrupt("break", 11);
- case 9:
- return _context3.abrupt("break", 11);
- case 10:
- return _context3.abrupt("break", 11);
- case 11:
- _context3.t1 = options.hyperlinks;
- _context3.next = _context3.t1 === 'emit' ? 14 : _context3.t1 === 'cache' ? 16 : 18;
- break;
- case 14:
- emitHyperlinks = true;
- return _context3.abrupt("break", 19);
- case 16:
- _this2.hyperlinks = hyperlinks = {};
- return _context3.abrupt("break", 19);
- case 18:
- return _context3.abrupt("break", 19);
- case 19:
- if (!(!emitSheet && !emitHyperlinks && !hyperlinks)) {
- _context3.next = 21;
- break;
- }
- return _context3.abrupt("return");
- case 21:
- // references
- _this2$workbook = _this2.workbook, sharedStrings = _this2$workbook.sharedStrings, styles = _this2$workbook.styles, properties = _this2$workbook.properties; // xml position
- inCols = false;
- inRows = false;
- inHyperlinks = false; // parse state
- cols = null;
- row = null;
- c = null;
- current = null;
- _iteratorNormalCompletion3 = true;
- _didIteratorError3 = false;
- _context3.prev = 31;
- _iterator3 = _asyncIterator(parseSax(iterator));
- case 33:
- _context3.next = 35;
- return _awaitAsyncGenerator(_iterator3.next());
- case 35:
- _step3 = _context3.sent;
- _iteratorNormalCompletion3 = _step3.done;
- _context3.next = 39;
- return _awaitAsyncGenerator(_step3.value);
- case 39:
- _value3 = _context3.sent;
- if (_iteratorNormalCompletion3) {
- _context3.next = 153;
- break;
- }
- events = _value3;
- worksheetEvents = [];
- _iterator6 = _createForOfIteratorHelper(events);
- _context3.prev = 44;
- _iterator6.s();
- case 46:
- if ((_step6 = _iterator6.n()).done) {
- _context3.next = 139;
- break;
- }
- _step6$value = _step6.value, eventType = _step6$value.eventType, value = _step6$value.value;
- if (!(eventType === 'opentag')) {
- _context3.next = 82;
- break;
- }
- node = value;
- if (!emitSheet) {
- _context3.next = 71;
- break;
- }
- _context3.t2 = node.name;
- _context3.next = _context3.t2 === 'cols' ? 54 : _context3.t2 === 'sheetData' ? 57 : _context3.t2 === 'col' ? 59 : _context3.t2 === 'row' ? 61 : _context3.t2 === 'c' ? 63 : _context3.t2 === 'f' ? 65 : _context3.t2 === 'v' ? 67 : _context3.t2 === 'mergeCell' ? 69 : 70;
- break;
- case 54:
- inCols = true;
- cols = [];
- return _context3.abrupt("break", 71);
- case 57:
- inRows = true;
- return _context3.abrupt("break", 71);
- case 59:
- if (inCols) {
- cols.push({
- min: parseInt(node.attributes.min, 10),
- max: parseInt(node.attributes.max, 10),
- width: parseFloat(node.attributes.width),
- styleId: parseInt(node.attributes.style || '0', 10)
- });
- }
- return _context3.abrupt("break", 71);
- case 61:
- if (inRows) {
- r = parseInt(node.attributes.r, 10);
- row = new Row(_this2, r);
- if (node.attributes.ht) {
- row.height = parseFloat(node.attributes.ht);
- }
- if (node.attributes.s) {
- styleId = parseInt(node.attributes.s, 10);
- style = styles.getStyleModel(styleId);
- if (style) {
- row.style = style;
- }
- }
- }
- return _context3.abrupt("break", 71);
- case 63:
- if (row) {
- c = {
- ref: node.attributes.r,
- s: parseInt(node.attributes.s, 10),
- t: node.attributes.t
- };
- }
- return _context3.abrupt("break", 71);
- case 65:
- if (c) {
- current = c.f = {
- text: ''
- };
- }
- return _context3.abrupt("break", 71);
- case 67:
- if (c) {
- current = c.v = {
- text: ''
- };
- }
- return _context3.abrupt("break", 71);
- case 69:
- return _context3.abrupt("break", 71);
- case 70:
- return _context3.abrupt("break", 71);
- case 71:
- if (!(emitHyperlinks || hyperlinks)) {
- _context3.next = 80;
- break;
- }
- _context3.t3 = node.name;
- _context3.next = _context3.t3 === 'hyperlinks' ? 75 : _context3.t3 === 'hyperlink' ? 77 : 79;
- break;
- case 75:
- inHyperlinks = true;
- return _context3.abrupt("break", 80);
- case 77:
- if (inHyperlinks) {
- hyperlink = {
- ref: node.attributes.ref,
- rId: node.attributes['r:id']
- };
- if (emitHyperlinks) {
- worksheetEvents.push({
- eventType: 'hyperlink',
- value: hyperlink
- });
- } else {
- hyperlinks[hyperlink.ref] = hyperlink;
- }
- }
- return _context3.abrupt("break", 80);
- case 79:
- return _context3.abrupt("break", 80);
- case 80:
- _context3.next = 137;
- break;
- case 82:
- if (!(eventType === 'text')) {
- _context3.next = 86;
- break;
- }
- // only text data is for sheet values
- if (emitSheet) {
- if (current) {
- current.text += value;
- }
- }
- _context3.next = 137;
- break;
- case 86:
- if (!(eventType === 'closetag')) {
- _context3.next = 137;
- break;
- }
- _node = value;
- if (!emitSheet) {
- _context3.next = 130;
- break;
- }
- _context3.t4 = _node.name;
- _context3.next = _context3.t4 === 'cols' ? 92 : _context3.t4 === 'sheetData' ? 95 : _context3.t4 === 'row' ? 97 : _context3.t4 === 'c' ? 101 : 129;
- break;
- case 92:
- inCols = false;
- _this2._columns = Column.fromModel(cols);
- return _context3.abrupt("break", 130);
- case 95:
- inRows = false;
- return _context3.abrupt("break", 130);
- case 97:
- _this2._dimensions.expandRow(row);
- worksheetEvents.push({
- eventType: 'row',
- value: row
- });
- row = null;
- return _context3.abrupt("break", 130);
- case 101:
- if (!(row && c)) {
- _context3.next = 128;
- break;
- }
- address = colCache.decodeAddress(c.ref);
- cell = row.getCell(address.col);
- if (c.s) {
- _style = styles.getStyleModel(c.s);
- if (_style) {
- cell.style = _style;
- }
- }
- if (!c.f) {
- _context3.next = 111;
- break;
- }
- cellValue = {
- formula: c.f.text
- };
- if (c.v) {
- if (c.t === 'str') {
- cellValue.result = utils.xmlDecode(c.v.text);
- } else {
- cellValue.result = parseFloat(c.v.text);
- }
- }
- cell.value = cellValue;
- _context3.next = 126;
- break;
- case 111:
- if (!c.v) {
- _context3.next = 126;
- break;
- }
- _context3.t5 = c.t;
- _context3.next = _context3.t5 === 's' ? 115 : _context3.t5 === 'str' ? 118 : _context3.t5 === 'e' ? 120 : _context3.t5 === 'b' ? 122 : 124;
- break;
- case 115:
- index = parseInt(c.v.text, 10);
- if (sharedStrings) {
- cell.value = sharedStrings[index];
- } else {
- cell.value = {
- sharedString: index
- };
- }
- return _context3.abrupt("break", 126);
- case 118:
- cell.value = utils.xmlDecode(c.v.text);
- return _context3.abrupt("break", 126);
- case 120:
- cell.value = {
- error: c.v.text
- };
- return _context3.abrupt("break", 126);
- case 122:
- cell.value = parseInt(c.v.text, 10) !== 0;
- return _context3.abrupt("break", 126);
- case 124:
- if (utils.isDateFmt(cell.numFmt)) {
- cell.value = utils.excelToDate(parseFloat(c.v.text), properties.model && properties.model.date1904);
- } else {
- cell.value = parseFloat(c.v.text);
- }
- return _context3.abrupt("break", 126);
- case 126:
- if (hyperlinks) {
- _hyperlink = hyperlinks[c.ref];
- if (_hyperlink) {
- cell.text = cell.value;
- cell.value = undefined;
- cell.hyperlink = _hyperlink;
- }
- }
- c = null;
- case 128:
- return _context3.abrupt("break", 130);
- case 129:
- return _context3.abrupt("break", 130);
- case 130:
- if (!(emitHyperlinks || hyperlinks)) {
- _context3.next = 137;
- break;
- }
- _context3.t6 = _node.name;
- _context3.next = _context3.t6 === 'hyperlinks' ? 134 : 136;
- break;
- case 134:
- inHyperlinks = false;
- return _context3.abrupt("break", 137);
- case 136:
- return _context3.abrupt("break", 137);
- case 137:
- _context3.next = 46;
- break;
- case 139:
- _context3.next = 144;
- break;
- case 141:
- _context3.prev = 141;
- _context3.t7 = _context3["catch"](44);
- _iterator6.e(_context3.t7);
- case 144:
- _context3.prev = 144;
- _iterator6.f();
- return _context3.finish(144);
- case 147:
- if (!(worksheetEvents.length > 0)) {
- _context3.next = 150;
- break;
- }
- _context3.next = 150;
- return worksheetEvents;
- case 150:
- _iteratorNormalCompletion3 = true;
- _context3.next = 33;
- break;
- case 153:
- _context3.next = 159;
- break;
- case 155:
- _context3.prev = 155;
- _context3.t8 = _context3["catch"](31);
- _didIteratorError3 = true;
- _iteratorError3 = _context3.t8;
- case 159:
- _context3.prev = 159;
- _context3.prev = 160;
- if (!(!_iteratorNormalCompletion3 && _iterator3.return != null)) {
- _context3.next = 164;
- break;
- }
- _context3.next = 164;
- return _awaitAsyncGenerator(_iterator3.return());
- case 164:
- _context3.prev = 164;
- if (!_didIteratorError3) {
- _context3.next = 167;
- break;
- }
- throw _iteratorError3;
- case 167:
- return _context3.finish(164);
- case 168:
- return _context3.finish(159);
- case 169:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, null, [[31, 155, 159, 169], [44, 141, 144, 147], [160,, 164, 168]]);
- }))();
- }
- }, {
- key: "dimensions",
- get: function get() {
- return this._dimensions;
- } // =========================================================================
- // Columns
- // get the current columns array.
- }, {
- key: "columns",
- get: function get() {
- return this._columns;
- }
- }]);
- return WorksheetReader;
- }(EventEmitter);
- module.exports = WorksheetReader;
- //# sourceMappingURL=worksheet-reader.js.map
|