UNPKG

@syncfusion/ej2-spreadsheet

Version:

Feature-rich JavaScript Spreadsheet (Excel) control with built-in support for selection, editing, formatting, importing and exporting to Excel

1,511 lines (1,504 loc) 3.52 MB
import { isNullOrUndefined, Property, ChildProperty, Complex, getNumericObject, isUndefined as isUndefined$1, Internationalization, getNumberDependable, defaultCurrencyCode, IntlBase, cldrData, extend, Collection, getUniqueID, detach, getValue, Event as Event$1, NotifyPropertyChanges, Base, getComponent, closest, L10n, merge, Component, removeClass, Browser, setStyleAttribute as setStyleAttribute$1, attributes, formatUnit, addClass, append, compile, remove, EventHandler, select, initializeCSPTemplate, isObject, getInstance, createElement, selectAll, rippleEffect, enableRipple, classList } from '@syncfusion/ej2-base'; import { Query, Predicate, DataManager, Deferred, DataUtil } from '@syncfusion/ej2-data'; import { Tooltip, Dialog as Dialog$1, calculatePosition, isCollide, createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups'; import { Tab, TreeView, Toolbar, Item, Menu, MenuItem, ContextMenu as ContextMenu$1 } from '@syncfusion/ej2-navigations'; import { NumericTextBox, FormValidator, TextBox, ColorPicker as ColorPicker$1 } from '@syncfusion/ej2-inputs'; import { CheckBox, Button, RadioButton } from '@syncfusion/ej2-buttons'; import { DropDownList, ComboBox, AutoComplete } from '@syncfusion/ej2-dropdowns'; import { ListView } from '@syncfusion/ej2-lists'; import { DropDownButton, SplitButton } from '@syncfusion/ej2-splitbuttons'; import { beforeFltrcMenuOpen, filterCmenuSelect, filterCboxValue, filterDialogCreated, filterDialogClose, fltrPrevent, customFilterOpen, parentsUntil, toogleCheckbox, createCboxWithWrap, getUid, ExcelFilterBase, CheckBoxFilterBase } from '@syncfusion/ej2-grids'; import { Chart as Chart$1, ColumnSeries, LineSeries, BarSeries, AreaSeries, StackingColumnSeries, StackingLineSeries, StackingBarSeries, ScatterSeries, StackingAreaSeries, Category, Legend, Tooltip as Tooltip$1, DataLabel, DateTime, AccumulationChart, PieSeries, AccumulationTooltip, AccumulationDataLabel, AccumulationLegend } from '@syncfusion/ej2-charts'; /** * To get range indexes. * * @param {string} range - Specifies the range. * @param {Workbook} [context] - Optional Workbook context to derive sheet information, used when the sheet name or index is provided. * @param {number} [sheetIndex] - Optional sheet index to resolve sheet-specific range when context is provided. * @returns {number[]} - To get range indexes. */ function getRangeIndexes(range, context, sheetIndex) { var cellindexes; var indexes = []; if (range) { var sheet = void 0; if (context && !isNullOrUndefined(sheetIndex)) { sheet = getSheet(context, sheetIndex); } range = range.lastIndexOf('!') > -1 ? range.substring(range.lastIndexOf('!') + 1) : range; range = range.indexOf(':') === -1 ? range + ':' + range : range; var containsAlphabetsAndDigits = new RegExp(/^(?=.*[a-zA-Z])(?=.*\d)/g); if (!containsAlphabetsAndDigits.test(range)) { var refArr = range.split(':'); range = isNullOrUndefined(range.match(/[0-9]/)) ? (refArr[0] + '1:' + refArr[1] + (sheet ? (sheet.rowCount - 1) : '1')) : ('A' + refArr[0] + ':' + (sheet ? getColumnHeaderText(sheet.colCount) : 'A') + refArr[1]); } range.split(':').forEach(function (address) { cellindexes = getCellIndexes(address); indexes.push(cellindexes[0]); indexes.push(cellindexes[1]); }); } return indexes; } /** * To get single cell indexes * * @param {string} address - Specifies the address. * @returns {number[]} - To get single cell indexes */ function getCellIndexes(address) { return [parseInt(address.match(/\d+/)[0], 10) - 1, getColIndex(address.match(/[A-Z]+/i)[0].toUpperCase())]; } /** * To get column index from text. * * @hidden * @param {string} text - Specifies the text. * @returns {number} - To get column index from text. */ function getColIndex(text) { var colIdx = 0; text = text.split('').reverse().join(''); for (var i = text.length - 1; i >= 0; i--) { colIdx += (text[i].charCodeAt(0) - 64) * (Math.pow(26, i)); } return colIdx - 1; } /** * To get cell address from given row and column index. * * @param {number} sRow - Specifies the row. * @param {number} sCol - Specifies the col. * @returns {string} - To get cell address from given row and column index. */ function getCellAddress(sRow, sCol) { return getColumnHeaderText(sCol + 1) + (sRow + 1); } /** * To get range address from given range indexes. * * @param {number[]} range - Specifies the range. * @returns {string} - To get range address from given range indexes. */ function getRangeAddress(range) { return getCellAddress(range[0], range[1]) + ':' + (!isNullOrUndefined(range[2]) ? getCellAddress(range[2], range[3]) : getCellAddress(range[0], range[1])); } /** * To get column header cell text * * @param {number} colIndex - Specifies the colIndex. * @returns {string} - Get Column Header Text */ function getColumnHeaderText(colIndex) { var alphabet = 'Z'; if (colIndex / 26 > 1) { return getColumnHeaderText((colIndex % 26 === 0) ? (colIndex / 26 - 1) : Math.floor(colIndex / 26)) + String.fromCharCode((colIndex % 26) === 0 ? alphabet.charCodeAt(0) : 64 + (colIndex % 26)); } else { return String.fromCharCode(64 + (colIndex)); } } /** * @hidden * @param {SheetModel} address - Specifies the address. * @param {Workbook} [context] - Optional Workbook context to derive sheet information, used when the sheet name or index is provided. * @param {number} [sheetIndex] - Optional sheet index to resolve sheet-specific range when context is provided. * @returns {number[]} - Get Indexes From Address */ function getIndexesFromAddress(address, context, sheetIndex) { return getRangeIndexes(getRangeFromAddress(address), context, sheetIndex); } /** * @hidden * @param {SheetModel} address - Specifies the address. * @returns {string} - Get Range From Address. */ function getRangeFromAddress(address) { var sheetRefIndex = address.lastIndexOf('!'); return sheetRefIndex > -1 ? address.substring(sheetRefIndex + 1) : address; } /** * Get complete address for selected range * * @hidden * @param {SheetModel} sheet - Specifies the sheet. * @returns {string} - Get complete address for selected range */ function getAddressFromSelectedRange(sheet) { return sheet.name + '!' + sheet.selectedRange; } /** * @param {Workbook} context - Specifies the context. * @param {string} address - Specifies the address. * @returns {Object} - To get Address Info * @hidden */ function getAddressInfo(context, address) { var sheetIndex = getSheetIndexFromAddress(context, address); return { sheetIndex: sheetIndex, indices: getIndexesFromAddress(address, context, sheetIndex) }; } /** * @param {Workbook} context - Specifies the context. * @param {string} address - Specifies the address. * @returns {number} - return the sheet index. * @hidden */ function getSheetIndexFromAddress(context, address) { var sIdx; if (address.indexOf('!') > -1) { sIdx = getSheetIndex(context, getSheetNameFromAddress(address)); } else { sIdx = context.activeSheetIndex; } return sIdx; } /** * Given range will be swapped/arranged in increasing order. * * @hidden * @param {number[]} range - Specifies the range. * @returns {number[]} - Returns the bool value. */ function getSwapRange(range) { var clonedRange = range.slice(); if (range[0] > range[2]) { swap(clonedRange, 0, 2); } if (range[1] > range[3]) { swap(clonedRange, 1, 3); } return clonedRange; } /** * Interchange values in an array * * @param {number[]} range - Specifies the range. * @param {number} x - Specifies the x. * @param {number} y - Specifies the y. * @returns {void} - Interchange values in an array. */ function swap(range, x, y) { var tmp = range[x]; range[x] = range[y]; range[y] = tmp; } /** * @hidden * @param {number[]} range - Specifies the range. * @returns {boolean} - Returns the bool value. */ function isSingleCell(range) { return range[0] === range[2] && range[1] === range[3]; } /** * Worker task. * * @param {Object} context - Specify the context. * @param {Function | Object} taskFn - Specify the task. * @param {Function} callbackFn - Specify the callbackFn. * @param {Object[]} data - Specify the data. * @param {boolean} preventCallback - Specify the preventCallback. * @param {Workbook} parent - Specify the Workbook instance. * @returns {WorkerHelper} - Worker task. */ function executeTaskAsync(context, taskFn, callbackFn, data, preventCallback, parent) { return new WorkerHelper(context, taskFn, callbackFn, data, preventCallback, parent); } /** * @hidden * * The `WorkerHelper` module is used to perform multiple actions using Web Worker asynchronously. */ var WorkerHelper = /** @__PURE__ @class */ (function () { /** * Constructor for WorkerHelper module in Workbook library. * * @private * @param {Object} context - Specify the context. * @param {Function | Object} task - Specify the task. * @param {Function} defaultListener - Specify the defaultListener. * @param {Object[]} taskData - Specify the taskData. * @param {boolean} preventCallback - Specify the preventCallback. * @param {Workbook} parent - Specify the Workbook instance. */ function WorkerHelper(context, task, defaultListener, taskData, preventCallback, parent) { this.preventCallback = false; this.context = context; this.workerTask = task; this.defaultListener = defaultListener; this.workerData = taskData; this.parent = parent; if (preventCallback) { this.preventCallback = true; } this.initWorker(); } /** * To terminate the worker task. * * @private * @returns {void} - To terminate the worker task. */ WorkerHelper.prototype.terminate = function () { this.worker.terminate(); URL.revokeObjectURL(this.workerUrl); }; /** * To initiate the worker. * * @private * @returns {void} - To initiate the worker. */ WorkerHelper.prototype.initWorker = function () { var taskBlob = new Blob([this.getFnCode()], { type: 'text/javascript' }); this.workerUrl = URL.createObjectURL(taskBlob); this.worker = new Worker(this.workerUrl); this.worker.onmessage = this.messageFromWorker.bind(this); this.worker.onerror = this.onError.bind(this); if (!this.parent.isVue) { this.worker.postMessage(this.workerData); } else { var clonedData = JSON.parse(JSON.stringify(this.workerData)); this.worker.postMessage(clonedData); } }; /** * Method for getting response from worker. * * @param {MessageEvent} args - Specify the args. * @returns {void} - Method for getting response from worker. * @private */ WorkerHelper.prototype.messageFromWorker = function (args) { this.terminate(); this.defaultListener.apply(this.context, [args.data]); }; /** * Method for getting error message from worker if failed. * * @param {ErrorEvent} args - Specify the args. * @returns {void} - Method for getting error message from worker if failed. * @private */ WorkerHelper.prototype.onError = function (args) { this.terminate(); if (args.message && args.message.includes('FormData')) { this.defaultListener.apply(this.context, [{ isFormDataError: true }]); } else { throw args.message || args; } }; /** * Construct function code for worker. * * @private * @returns {string} - Construct function code for worker. */ WorkerHelper.prototype.getFnCode = function () { var workerCode = ''; var i; var keys; var workerFunction = ''; var isHaveFunction = false; if (typeof this.workerTask === 'function') { if (this.workerTask.toString().indexOf('function') < 0) { workerFunction = 'function ' + this.workerTask.toString(); } else { workerFunction = this.workerTask.toString(); isHaveFunction = true; } workerCode += ('self.workerTask = ' + workerFunction + '; \n'); } else { if (typeof this.workerTask === 'object') { keys = Object.keys(this.workerTask); for (i = 0; i < keys.length; i++) { if (this.workerTask[keys[i]].toString().indexOf('function') < 0) { workerFunction = 'function ' + this.workerTask[keys[i]].toString(); } else { workerFunction = this.workerTask[keys[i]].toString(); isHaveFunction = true; } workerCode += ((i === 0 ? 'self.workerTask' : keys[i]) + '= ' + workerFunction + '; \n'); } } } workerCode += 'self.onmessage = ' + (isHaveFunction ? '' : ' function ') + (this.preventCallback ? this.getMessageFn.toString() : this.getCallbackMessageFn.toString()) + '; \n'; return workerCode; }; /** * Get default worker task with callback. * * @private * @param {MessageEvent} args - Specify the args. * @returns {void} - Get default worker task without callback. */ WorkerHelper.prototype.getCallbackMessageFn = function (args) { postMessage(this.workerTask.apply(this, args.data)); }; /** * Get default worker task without callback. * * @private * @param {MessageEvent} args - Specify the args. * @returns {void} - Get default worker task without callback. */ WorkerHelper.prototype.getMessageFn = function (args) { this.workerTask.apply(this, args.data); }; return WorkerHelper; }()); /** * To get Workbook required modules. * * @hidden * @param {Workbook} context - Specifies the context. * @param {ModuleDeclaration[]} modules - Specifies the modules. * @returns {ModuleDeclaration[]} - To get Workbook required modules. */ function getWorkbookRequiredModules(context, modules) { if (modules === void 0) { modules = []; } modules.push({ member: 'dataBind', args: [context] }); modules.push({ member: 'workbookProtectSheet', args: [context] }); if (context.allowSave) { modules.push({ member: 'workbookSave', args: [context] }); } if (context.allowPrint) { modules.push({ member: 'print', args: [context] }); } if (context.allowOpen) { modules.push({ member: 'workbookOpen', args: [context] }); } if (context.allowEditing) { modules.push({ member: 'workbookEdit', args: [context] }); modules.push({ member: 'workbookFormula', args: [context] }); } if (context.allowNumberFormatting) { modules.push({ member: 'workbookNumberFormat', args: [context] }); } if (context.allowCellFormatting) { modules.push({ member: 'workbookcellformat', args: [context] }); } if (context.allowSorting) { modules.push({ member: 'workbookSort', args: [context] }); } if (context.allowHyperlink) { modules.push({ member: 'workbookHyperlink', args: [context] }); } if (context.allowFiltering) { modules.push({ member: 'workbookFilter', args: [context] }); } if (context.allowFindAndReplace) { modules.push({ member: 'workbookfindAndReplace', args: [context] }); } if (context.allowInsert) { modules.push({ member: 'workbookinsert', args: [context] }); } if (context.allowDelete) { modules.push({ member: 'workbookdelete', args: [context] }); } if (context.allowDataValidation) { modules.push({ member: 'workbookDataValidation', args: [context] }); } if (context.allowMerge) { modules.push({ member: 'workbookmerge', args: [context] }); } if (context.allowCellFormatting) { modules.push({ member: 'workbookConditionalFormatting', args: [context] }); } if (context.allowImage) { modules.push({ member: 'workbookImage', args: [context] }); } if (context.allowChart) { modules.push({ member: 'workbookChart', args: [context] }); } if (context.allowAutoFill) { modules.push({ member: 'workbookautofill', args: [context] }); } return modules; } var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; /** * Represents the cell style. */ var CellStyle = /** @__PURE__ @class */ (function (_super) { __extends(CellStyle, _super); function CellStyle() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('Calibri') ], CellStyle.prototype, "fontFamily", void 0); __decorate([ Property('bottom') ], CellStyle.prototype, "verticalAlign", void 0); __decorate([ Property('left') ], CellStyle.prototype, "textAlign", void 0); __decorate([ Property('0pt') ], CellStyle.prototype, "textIndent", void 0); __decorate([ Property('#000000') ], CellStyle.prototype, "color", void 0); __decorate([ Property('#ffffff') ], CellStyle.prototype, "backgroundColor", void 0); __decorate([ Property('normal') ], CellStyle.prototype, "fontWeight", void 0); __decorate([ Property('normal') ], CellStyle.prototype, "fontStyle", void 0); __decorate([ Property('11pt') ], CellStyle.prototype, "fontSize", void 0); __decorate([ Property('none') ], CellStyle.prototype, "textDecoration", void 0); __decorate([ Property('') ], CellStyle.prototype, "border", void 0); __decorate([ Property('') ], CellStyle.prototype, "borderTop", void 0); __decorate([ Property('') ], CellStyle.prototype, "borderBottom", void 0); __decorate([ Property('') ], CellStyle.prototype, "borderLeft", void 0); __decorate([ Property('') ], CellStyle.prototype, "borderRight", void 0); return CellStyle; }(ChildProperty)); /** * Represents the Filter Collection. * */ var FilterCollection = /** @__PURE__ @class */ (function (_super) { __extends(FilterCollection, _super); function FilterCollection() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property() ], FilterCollection.prototype, "sheetIndex", void 0); __decorate([ Property() ], FilterCollection.prototype, "filterRange", void 0); __decorate([ Property(false) ], FilterCollection.prototype, "hasFilter", void 0); __decorate([ Property() ], FilterCollection.prototype, "column", void 0); __decorate([ Property() ], FilterCollection.prototype, "criteria", void 0); __decorate([ Property() ], FilterCollection.prototype, "value", void 0); __decorate([ Property() ], FilterCollection.prototype, "dataType", void 0); __decorate([ Property() ], FilterCollection.prototype, "predicates", void 0); return FilterCollection; }(ChildProperty)); /** * Represents the sort Collection. * */ var SortCollection = /** @__PURE__ @class */ (function (_super) { __extends(SortCollection, _super); function SortCollection() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property() ], SortCollection.prototype, "sortRange", void 0); __decorate([ Property() ], SortCollection.prototype, "columnIndex", void 0); __decorate([ Property() ], SortCollection.prototype, "order", void 0); __decorate([ Property() ], SortCollection.prototype, "sheetIndex", void 0); return SortCollection; }(ChildProperty)); /** * Represents a defined name in the spreadsheet. * A defined name is a meaningful identifier that refers to a specific cell or range, and can be used in formulas. */ var DefineName = /** @__PURE__ @class */ (function (_super) { __extends(DefineName, _super); function DefineName() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('') ], DefineName.prototype, "name", void 0); __decorate([ Property('') ], DefineName.prototype, "scope", void 0); __decorate([ Property('') ], DefineName.prototype, "comment", void 0); __decorate([ Property('') ], DefineName.prototype, "refersTo", void 0); return DefineName; }(ChildProperty)); /** * Configures the Protect behavior for the spreadsheet. * */ var ProtectSettings = /** @__PURE__ @class */ (function (_super) { __extends(ProtectSettings, _super); function ProtectSettings() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property(false) ], ProtectSettings.prototype, "selectCells", void 0); __decorate([ Property(false) ], ProtectSettings.prototype, "selectUnLockedCells", void 0); __decorate([ Property(false) ], ProtectSettings.prototype, "formatCells", void 0); __decorate([ Property(false) ], ProtectSettings.prototype, "formatRows", void 0); __decorate([ Property(false) ], ProtectSettings.prototype, "formatColumns", void 0); __decorate([ Property(false) ], ProtectSettings.prototype, "insertLink", void 0); return ProtectSettings; }(ChildProperty)); /** * Represents the Hyperlink. * */ var Hyperlink = /** @__PURE__ @class */ (function (_super) { __extends(Hyperlink, _super); function Hyperlink() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('') ], Hyperlink.prototype, "address", void 0); return Hyperlink; }(ChildProperty)); /** * Represents the DataValidation. */ var Validation = /** @__PURE__ @class */ (function (_super) { __extends(Validation, _super); function Validation() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('WholeNumber') ], Validation.prototype, "type", void 0); __decorate([ Property('Between') ], Validation.prototype, "operator", void 0); __decorate([ Property('0') ], Validation.prototype, "value1", void 0); __decorate([ Property('0') ], Validation.prototype, "value2", void 0); __decorate([ Property(true) ], Validation.prototype, "ignoreBlank", void 0); __decorate([ Property(true) ], Validation.prototype, "inCellDropDown", void 0); __decorate([ Property(false) ], Validation.prototype, "isHighlighted", void 0); __decorate([ Property('') ], Validation.prototype, "address", void 0); return Validation; }(ChildProperty)); /** * Represents the Format. */ var Format = /** @__PURE__ @class */ (function (_super) { __extends(Format, _super); function Format() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('General') ], Format.prototype, "format", void 0); __decorate([ Complex({}, CellStyle) ], Format.prototype, "style", void 0); __decorate([ Property(true) ], Format.prototype, "isLocked", void 0); return Format; }(ChildProperty)); /** * Represents the Conditional Formatting. * */ var ConditionalFormat = /** @__PURE__ @class */ (function (_super) { __extends(ConditionalFormat, _super); function ConditionalFormat() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('GreaterThan') ], ConditionalFormat.prototype, "type", void 0); __decorate([ Complex({}, Format) ], ConditionalFormat.prototype, "format", void 0); __decorate([ Property('RedFT') ], ConditionalFormat.prototype, "cFColor", void 0); __decorate([ Property('') ], ConditionalFormat.prototype, "value", void 0); __decorate([ Property('') ], ConditionalFormat.prototype, "range", void 0); __decorate([ Property('') ], ConditionalFormat.prototype, "action", void 0); return ConditionalFormat; }(ChildProperty)); /** * Represents the Legend. * */ var LegendSettings = /** @__PURE__ @class */ (function (_super) { __extends(LegendSettings, _super); function LegendSettings() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property(true) ], LegendSettings.prototype, "visible", void 0); __decorate([ Property('Auto') ], LegendSettings.prototype, "position", void 0); return LegendSettings; }(ChildProperty)); /** * Represents the DataLabelSettings. * */ var DataLabelSettings = /** @__PURE__ @class */ (function (_super) { __extends(DataLabelSettings, _super); function DataLabelSettings() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property(false) ], DataLabelSettings.prototype, "visible", void 0); __decorate([ Property('Auto') ], DataLabelSettings.prototype, "position", void 0); return DataLabelSettings; }(ChildProperty)); /** * Represents the Border. * */ var Border = /** @__PURE__ @class */ (function (_super) { __extends(Border, _super); function Border() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('') ], Border.prototype, "color", void 0); __decorate([ Property(1) ], Border.prototype, "width", void 0); return Border; }(ChildProperty)); /** * Represents the MarkerSettings. * */ var MarkerSettings = /** @__PURE__ @class */ (function (_super) { __extends(MarkerSettings, _super); function MarkerSettings() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property(false) ], MarkerSettings.prototype, "visible", void 0); __decorate([ Property('Circle') ], MarkerSettings.prototype, "shape", void 0); __decorate([ Property(5) ], MarkerSettings.prototype, "size", void 0); __decorate([ Property(null) ], MarkerSettings.prototype, "fill", void 0); __decorate([ Property(true) ], MarkerSettings.prototype, "isFilled", void 0); __decorate([ Complex({}, Border) ], MarkerSettings.prototype, "border", void 0); return MarkerSettings; }(ChildProperty)); /** * Specifies the major grid lines in the `axis`. * */ var MajorGridLines = /** @__PURE__ @class */ (function (_super) { __extends(MajorGridLines, _super); function MajorGridLines() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property(0) ], MajorGridLines.prototype, "width", void 0); return MajorGridLines; }(ChildProperty)); /** * Specifies the minor grid lines in the `axis`. * */ var MinorGridLines = /** @__PURE__ @class */ (function (_super) { __extends(MinorGridLines, _super); function MinorGridLines() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property(0) ], MinorGridLines.prototype, "width", void 0); return MinorGridLines; }(ChildProperty)); /** * Represents the axis. * */ var Axis = /** @__PURE__ @class */ (function (_super) { __extends(Axis, _super); function Axis() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('') ], Axis.prototype, "title", void 0); __decorate([ Complex({}, MajorGridLines) ], Axis.prototype, "majorGridLines", void 0); __decorate([ Complex({}, MinorGridLines) ], Axis.prototype, "minorGridLines", void 0); __decorate([ Property(true) ], Axis.prototype, "visible", void 0); return Axis; }(ChildProperty)); /** * Represents the Chart. */ var Chart = /** @__PURE__ @class */ (function (_super) { __extends(Chart, _super); function Chart() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('Line') ], Chart.prototype, "type", void 0); __decorate([ Property('Material') ], Chart.prototype, "theme", void 0); __decorate([ Property(false) ], Chart.prototype, "isSeriesInRows", void 0); __decorate([ Complex({}, MarkerSettings) ], Chart.prototype, "markerSettings", void 0); __decorate([ Property('') ], Chart.prototype, "range", void 0); __decorate([ Property('') ], Chart.prototype, "id", void 0); __decorate([ Property('') ], Chart.prototype, "title", void 0); __decorate([ Property(290) ], Chart.prototype, "height", void 0); __decorate([ Property(480) ], Chart.prototype, "width", void 0); __decorate([ Property(0) ], Chart.prototype, "top", void 0); __decorate([ Property(0) ], Chart.prototype, "left", void 0); __decorate([ Complex({}, LegendSettings) ], Chart.prototype, "legendSettings", void 0); __decorate([ Complex({}, Axis) ], Chart.prototype, "primaryXAxis", void 0); __decorate([ Complex({}, Axis) ], Chart.prototype, "primaryYAxis", void 0); __decorate([ Complex({}, DataLabelSettings) ], Chart.prototype, "dataLabelSettings", void 0); return Chart; }(ChildProperty)); /** * Represents the Image. */ var Image$1 = /** @__PURE__ @class */ (function (_super) { __extends(Image, _super); function Image() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('') ], Image.prototype, "src", void 0); __decorate([ Property('') ], Image.prototype, "id", void 0); __decorate([ Property(300) ], Image.prototype, "height", void 0); __decorate([ Property(400) ], Image.prototype, "width", void 0); __decorate([ Property(0) ], Image.prototype, "top", void 0); __decorate([ Property(0) ], Image.prototype, "left", void 0); return Image; }(ChildProperty)); /** * Represents the AutoFillSettings. */ var AutoFillSettings = /** @__PURE__ @class */ (function (_super) { __extends(AutoFillSettings, _super); function AutoFillSettings() { return _super !== null && _super.apply(this, arguments) || this; } __decorate([ Property('FillSeries') ], AutoFillSettings.prototype, "fillType", void 0); __decorate([ Property(true) ], AutoFillSettings.prototype, "showFillOptions", void 0); return AutoFillSettings; }(ChildProperty)); /** * Specifies Workbook internal events. */ /** @hidden */ var workbookDestroyed = 'workbookDestroyed'; /** @hidden */ var updateSheetFromDataSource = 'updateSheetFromDataSource'; /** @hidden */ var dataSourceChanged = 'dataSourceChanged'; /** @hidden */ var dataChanged = 'dataChanged'; /** @hidden */ var triggerDataChange = 'triggerDataChange'; /** @hidden */ var workbookOpen = 'workbookOpen'; /** @hidden */ var beginSave = 'beginSave'; /** @hidden */ var beginAction = 'actionBegin'; /** @hidden */ var sortImport = 'sortImport'; /** @hidden */ var findToolDlg = 'findToolDlg'; /** @hidden */ var exportDialog = 'exportDialog'; /** @hidden */ var setFilteredCollection = 'setFilteredCollection'; /** @hidden */ var saveCompleted = 'saveCompleted'; /** @hidden */ var applyNumberFormatting = 'applyNumber'; /** @hidden */ var getFormattedCellObject = 'getFormattedCell'; /** @hidden */ var calculateFormula = 'calculateFormula'; /** @hidden */ var refreshCellElement = 'refreshCellElem'; /** @hidden */ var setCellFormat = 'setCellFormat'; /** @hidden */ var findAllValues = 'findAllValues'; /** @hidden */ var textDecorationUpdate = 'textDecorationUpdate'; /** @hidden */ var applyCellFormat = 'applyCellFormat'; /** @hidden */ var updateUsedRange = 'updateUsedRange'; /** @hidden */ var updateRowColCount = 'updateRowColCount'; /** @hidden */ var workbookFormulaOperation = 'workbookFormulaOperation'; /** @hidden */ var workbookEditOperation = 'workbookEditOperation'; /** @hidden */ var checkDateFormat = 'checkDateFormat'; /** @hidden */ var checkNumberFormat = 'checkNumberFormat'; /** @hidden */ var parseDecimalNumber = 'parseDecimalNumber'; /** @hidden */ var getFormattedBarText = 'getFormattedBarText'; /** @hidden */ var activeCellChanged = 'activeCellChanged'; /** @hidden */ var openSuccess = 'openSuccess'; /** @hidden */ var openFailure = 'openFailure'; /** @hidden */ var sheetCreated = 'sheetCreated'; /** @hidden */ var sheetsDestroyed = 'sheetsDestroyed'; /** @hidden */ var aggregateComputation = 'aggregateComputation'; /** @hidden */ var getUniqueRange = 'getUniqueRange'; /** @hidden */ var removeUniquecol = 'removeUniquecol'; /** @hidden */ var checkUniqueRange = 'checkUniqueRange'; /** @hidden */ var reApplyFormula = 'reApplyFormula'; /** @hidden */ var clearFormulaDependentCells = 'clearFormulaDependentCells'; /** @hidden */ var formulaInValidation = 'formulaInValidation'; /** @hidden */ var beforeSort = 'beforeSort'; /** @hidden */ var initiateSort = 'initiateSort'; /** @hidden */ var updateSortedDataOnCell = 'updateSortedDataOnCell'; /** @hidden */ var sortComplete = 'sortComplete'; /** @hidden */ var sortRangeAlert = 'sortRangeAlert'; /** @hidden */ var initiatelink = 'initiatelink'; /** @hidden */ var beforeHyperlinkCreate = 'beforeHyperlinkCreate'; /** @hidden */ var afterHyperlinkCreate = 'afterHyperlinkCreate'; /** @hidden */ var beforeHyperlinkClick = 'beforeHyperlinkClick'; /** @hidden */ var afterHyperlinkClick = 'afterHyperlinkClick'; /** @hidden */ var addHyperlink = 'addHyperlink'; /** @hidden */ var setLinkModel = 'setLinkModel'; /** @hidden */ var beforeFilter = 'beforeFilter'; /** @hidden */ var initiateFilter = 'initiateFilter'; /** @hidden */ var filterComplete = 'filterComplete'; /** @hidden */ var filterRangeAlert = 'filterRangeAlert'; /** @hidden */ var clearAllFilter = 'clearAllFilter'; /** @hidden */ var wrapEvent = 'wrapText'; /** @hidden */ var onSave = 'onSave'; /** @hidden */ var insert = 'insert'; /** @hidden */ var deleteAction = 'delete'; /** @hidden */ var insertModel = 'insertModel'; /** @hidden */ var deleteModel = 'deleteModel'; /** @hidden */ var isValidation = 'isValidation'; /** @hidden */ var cellValidation = 'cellValidation'; /** @hidden */ var addHighlight = 'addHighlight'; /** @hidden */ var dataValidate = 'dataValidate'; /** @hidden */ var find = 'find'; /** @hidden */ var goto = 'gotoHandler'; /** @hidden */ var findWorkbookHandler = 'findHandler'; /** @hidden */ var replace = 'replace'; /** @hidden */ var replaceAll = 'replaceAll'; /** @hidden */ var showFindAlert = 'showFindAlert'; /** @hidden */ var findKeyUp = 'findKeyUp'; /** @hidden */ var removeHighlight = 'removeHighlight'; /** @hidden */ var queryCellInfo = 'queryCellInfo'; /** @hidden */ var count = 'count'; /** @hidden */ var findCount = 'findCount'; /** @hidden */ var protectSheetWorkBook = 'protectSheet'; /** @hidden */ var updateToggle = 'updateToggleItem'; /** @hidden */ var protectsheetHandler = 'protectsheetHandler'; /** @hidden */ var replaceAllDialog = 'replaceAllDialog'; /** @hidden */ var unprotectsheetHandler = 'unprotectsheetHandler'; /** @hidden */ var workBookeditAlert = 'editAlert'; /** @hidden */ var workbookReadonlyAlert = 'readonlyAlert'; /** @hidden */ var setLockCells = 'setLockCells'; /** @hidden */ var applyLockCells = 'applyLockCells'; /** @hidden */ var setMerge = 'setMerge'; /** @hidden */ var applyMerge = 'applyMerge'; /** @hidden */ var mergedRange = 'mergedRange'; /** @hidden */ var activeCellMergedRange = 'activeCellMergedRange'; /** @hidden */ var insertMerge = 'insertMerge'; /** @hidden */ var hideShow = 'hideShow'; /** @hidden */ var setCFRule = 'setCFRule'; /** @hidden */ var applyCF = 'applyCF'; /** @hidden */ var clearCFRule = 'clearCFRule'; /** @hidden */ var clear = 'clear'; /** @hidden */ var clearCF = 'clearCF'; /** @hidden */ var setImage = 'setImage'; /** @hidden */ var setChart = 'setChart'; /** @hidden */ var initiateChart = 'initiateChart'; /** @hidden */ var refreshRibbonIcons = 'refreshRibbonIcons'; /** @hidden */ var refreshChart = 'refreshChart'; /** @hidden */ var refreshChartSize = 'refreshChartSize'; /** @hidden */ var deleteChartColl = 'deleteChartColl'; /** @hidden */ var initiateChartModel = 'initiateChartModel'; /** @hidden */ var focusChartBorder = 'focusChartBorder'; /** @hidden */ var saveError = 'saveError'; /** @hidden */ var updateHighlight = 'updateHighlight'; /** @hidden */ var beforeInsert = 'beforeInsert'; /** @hidden */ var beforeDelete = 'beforeDelete'; /** @hidden */ var deleteHyperlink = 'deleteHyperlink'; /** @hidden */ var moveOrDuplicateSheet = 'moveOrDuplicateSheet'; /** @hidden */ var setAutoFill = 'setAutoFill'; /** @hidden */ var refreshCell = 'refreshCell'; /** @hidden */ var getFillInfo = 'getFillInfo'; /** @hidden */ var getautofillDDB = 'getautofillDDB'; /** @hidden */ var rowFillHandler = 'rowFillHandler'; /** @hidden */ var getTextSpace = 'getTextSpace'; /** @hidden */ var refreshClipboard = 'refreshClipboard'; /** @hidden */ var updateView = 'updateView'; /** @hidden */ var selectionComplete = 'selectionComplete'; /** @hidden */ var refreshInsertDelete = 'refreshInsertDelete'; /** @hidden */ var getUpdatedFormulaOnInsertDelete = 'getUpdatedFormulaOnInsertDelete'; /** @hidden */ var beforeCellUpdate = 'beforeCellUpdate'; /** @hidden */ var duplicateSheetFilterHandler = 'duplicateSheetFilterHandler'; /** @hidden */ var unMerge = 'unMerge'; /** @hidden */ var checkFormulaRef = 'checkFormulaRef'; /** @hidden */ var parseFormulaArgument = 'parseFormulaArgument'; /** @hidden */ var getCellRefValue = 'getCellRefValue'; /** @hidden */ var commputeFormulaValue = 'commputeFormulaValue'; /** @hidden */ var getChartRowIdxFromClientY = 'getChartRowIdxFromClientY'; /** @hidden */ var getChartColIdxFromClientX = 'getChartColIdxFromClientX'; /** @hidden */ var refreshChartCellOnInit = 'refreshChartCellOnInit'; /** @hidden */ var localizedFormatAction = 'localizedFormatAction'; /** @hidden */ var moveSheetHandler = 'moveSheetHandler'; /** @hidden */ var addListValidationDropdown = 'addListValidationDropdown'; /** @hidden */ var sheetRenameUpdate = 'sheetRenameUpdate'; /** @hidden */ var updateSortCollection = 'updateSortCollection'; /** @hidden */ var importModelUpdate = 'importModelUpdate'; /** * Check the value of the cell is number with thousand separator and currency symbol and returns the parsed value. * * @param {CellModel} cell - Specifies the cell. * @param {string} locale - Specifies the locale. * @param {string} groupSep - Specifies the group separator. * @param {string} decimalSep - Specifies the decimal separator. * @param {string} currencySym - Specifies the currency Symbol. * @param {boolean} isFractionalType - Defines whether the value is a fractional type or not. * @param {boolean} checkCurrency - Specifies the currency check. * @returns {Object} - returns the parsed value. * @hidden */ function checkIsNumberAndGetNumber(cell, locale, groupSep, decimalSep, currencySym, isFractionalType, checkCurrency) { var cellValue = cell.value; if (cellValue && typeof cellValue === 'string') { if (cellValue.includes('\n')) { return { isNumber: false, value: cellValue }; } if (isNumber(cellValue)) { return { isNumber: true, value: cellValue }; } if (currencySym && cellValue.includes(currencySym) && (checkCurrency || cell.format.includes(currencySym) || cell.format.includes('$'))) { cellValue = cellValue.replace(currencySym, '').trim(); } if (groupSep && cellValue.includes(groupSep) && parseThousandSeparator(cellValue, locale, groupSep, decimalSep)) { cellValue = cellValue.split(groupSep).join('').trim(); } if (!decimalSep) { decimalSep = getNumericObject(locale).decimal; } if (decimalSep !== '.' && cellValue.includes(decimalSep)) { cellValue = cellValue.replace(decimalSep, '.').trim(); } if (isNumber(cellValue)) { return { isNumber: true, value: cellValue }; } if (isFractionalType && cellValue.split('/').length === 2) { try { var splittedVal = cellValue.split(' '); if (splittedVal.length === 2 && splittedVal[0].split('/').length === 1) { var result = evaluate(splittedVal[0]); var result1 = evaluate(splittedVal[1]); cellValue = result + result1; } else { cellValue = evaluate(cellValue); } return { isNumber: true, value: cellValue }; } catch (error) { return { isNumber: false, value: cellValue }; } } } else if (isNumber(cellValue)) { return { isNumber: true, value: cellValue }; } return { isNumber: false, value: cellValue }; } /** * @param {string} value - Specifies the value. * @param {string} locale - Specifies the locale. * @param {string} groupSep - Specifies the group separator. * @param {string} decimalSep - Specifies the decimal separator. * @returns {boolean} - Returns parsed thousand separator. * @hidden */ function parseThousandSeparator(value, locale, groupSep, decimalSep) { var isParsed = false; var number = 123456; var parsedNum = number.toLocaleString(locale); var splitedNum = parsedNum.split(groupSep).reverse(); var splitedValue = value.split(decimalSep)[0].split(groupSep); for (var i = 0; i < splitedValue.length; i++) { if (i === splitedValue.length - 1) { isParsed = splitedValue[i].length === splitedNum[0].length; } else { isParsed = !isUndefined$1(splitedNum[1]) && (i === 0 ? splitedValue[i].length <= splitedNum[1].length : splitedValue[i].length === splitedNum[1].length); } if (!isParsed) { break; } } return isParsed; } /** * Check whether the text is formula or not. * * @param {string} text - Specify the text. * @param {boolean} isEditing - Specify the isEditing. * @returns {boolean} - Check whether the text is formula or not. */ function checkIsFormula(text, isEditing) { return text && text[0] === '=' && (text.length > 1 || isEditing); } /** * Check whether the value is cell reference or not. * * @param {string} value - Specify the value to check. * @returns {boolean} - Returns boolean value */ function isCellReference(value) { var range = value; range = range.split('$').join(''); if (range.indexOf(':') > -1) { var rangeSplit = range.split(':'); if (isValidCellReference(rangeSplit[0]) && isValidCellReference(rangeSplit[1])) { return true; } } else if (range.indexOf(':') < 0) { if (isValidCellReference(range)) { return true; } } return false; } /** * Check whether the value is character or not. * * @param {string} value - Specify the value to check. * @returns {boolean} - Returns boolean value */ function isChar(value) { if ((value.charCodeAt(0) >= 65 && value.charCodeAt(0) <= 90) || (value.charCodeAt(0) >= 97 && value.charCodeAt(0) <= 122)) { return true; } return false; } /** * Check whether the range selection is on complete row. * * @param {SheetModel} sheet - Specify the sheet. * @param {number[]} range - Specify the range index. * @returns {boolean} - Returns boolean value * @hidden */ function isRowSelected(sheet, range) { return range[1] === 0 && range[3] === sheet.colCount - 1; } /** * Check whether the range selection is on complete column. * * @param {SheetModel} sheet - Specify the sheet. * @param {number[]} range - Specify the range index. * @returns {boolean} - Returns boolean value * @hidden */ function isColumnSelected(sheet, range) { return range[0] === 0 && range[2] === sheet.rowCount - 1; } /** * @param {number[]} range - Specify the range * @param {number} rowIdx - Specify the row index * @param {number} colIdx - Specify the col index * @returns {boolean} - Returns boolean value */ function inRange(range, rowIdx, colIdx) { return range && (rowIdx >= range[0] && rowIdx <= range[2] && colIdx >= range[1] && colIdx <= range[3]); } /** * @param {number[]} address - Specify the address * @param {number} rowIdx - Specify the row index * @param {number} colIdx - Specify the col index * @returns {boolean} - Returns boolean value */ function isInMultipleRange(address, rowIdx, colIdx) { var range; var isInRange; var splitedAddress = address.split(' '); for (var i = 0, len = splitedAddress.length; i < len; i++) { range = getRangeIndexes(splitedAddress[i]); isInRange = inRange(range, rowIdx, colIdx); if (isInRange) { break; } } return isInRange; } /** @hidden * @param {number[]} range - Specify the range * @param {number[]} testRange - Specify the test range * @param {boolean} isModify - Specify the boolean value * @returns {boolean} - Returns boolean value */ function isInRange(range, testRange, isModify) { var inRange = range[0] <= testRange[0] && range[2] >= testRange[2] && range[1] <= testRange[1] && range[3] >= testRange[3]; if (inRange) { return true; } if (isModify) { if (testRange[0] < range[0] && testRange[2] < range[0] || testRange[0] > range[2] && testRange[2] > range[2]) { return false; } else { if (testRange[0] < range[0] && testRange[2] > range[0]) { testRange[0] = range[0]; inRange = true; } if (testRange[2] > range[2]) { testRange[2] = range[2]; inRange = true; } } if (testRange[1] < range[1] && testRange[3] < range[1] || testRange[1] > range[3] && testRange[3] > range[3]) { return false; } else { if (testRange[1] < range[1] && testRange[3] > range[1]) { testRange[1] = range[1]; inRange = true; } if (testRange[3] > range[3]) { testRange[3] = range[3]; inRange = true; } } } return inRange; } /** * @hidden * @param {string} address - Specifies the address for whole column. * @param {number[]} testRange - Specifies range used to split the address. * @param {number} colIdx - Specifies the column index. * @returns {string} - returns the modified address. */ function getSplittedAddressForColumn(address, testRange, colIdx) { var colName = getColumnHeaderText(colIdx + 1); if (address) { address.split(' ').forEach(function (addrs) { var range = getRangeIndexes(addrs); if (isInRange(range, testRange)) { address = address.split(addrs).join(colName + (range[0] + 1) + ':' + colName + testRange[0] + ' ' + colName + (testRange[2] + 2) + ':' + colName + (range[2] + 1)); } else if (isInRange(range, testRange, true)) { var modifiedAddress = void 0; if (testRange[0] > range[0]) { modifiedAddress = colName + (range[0] + 1) + ':' + colName + testRange[0]; } else { modifiedAddress = colName + (testRange[2] + 2) + ':' + colName + (range[2] + 1); } address = address.split(addrs).join(modifiedAddress); } }); } else { address = colName + '1:' + colName +